Android 同时滚动多个文本视图
我有一个文件中的字符串,该文件存储在3个单独的文本视图中,因为我与单个文本视图存在对齐问题。如何仅滚动屏幕的这一部分以查看文件的所有内容Android 同时滚动多个文本视图,android,scroll,textview,text-files,Android,Scroll,Textview,Text Files,我有一个文件中的字符串,该文件存储在3个单独的文本视图中,因为我与单个文本视图存在对齐问题。如何仅滚动屏幕的这一部分以查看文件的所有内容 BufferedReader buf = new BufferedReader(new FileReader(file)); while((line = buf.readLine())!= null) { StringTokenizer st = new StringTokenizer(line); a = st.nextToken();
BufferedReader buf = new BufferedReader(new FileReader(file));
while((line = buf.readLine())!= null) {
StringTokenizer st = new StringTokenizer(line);
a = st.nextToken();
b = st.nextToken();
c = st.nextToken();
text1.append(a + '\n');
text2.append(b + '\n');
text3.append(c + '\n');
}
dp1.setText(text1);
dp2.setText(text2);
dp3.setText(text3);
您可以将文本视图放在XML文件的水平滚动视图中,如下所示
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView ... />
<TextView ... />
<TextView ... />
</HorizontalScrollView>
在布局文件中为您的设置android:ellipsize=“marquee”
,在设置文本的代码中设置setSelected(true)
。我希望这将对您有所帮助。如果需要,您可以使用以下xml并进行一些调整
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:id="@+id/dp1"... />
<TextView android:id="@+id/dp2"... />
<TextView android:id="@+id/dp3"... />
</HorizontalScrollView>
如果需要,可以使用垂直滚动条作为
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:scrollbars="vertical"
android:layout_height="set the height here" >
</ScrollView>
我试过这个,但似乎不起作用。它滚动屏幕中的固定区域,但不滚动文本视图中的实际列表。u放置滚动视图的方式存在一些问题。我已经试过了,它能正常工作。检查您的代码一次…:)无法将多个子项分配给水平滚动视图
。无法将多个子项分配给水平滚动视图
。
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:scrollbars="vertical"
android:layout_height="set the height here" >
</ScrollView>