我正在尝试在播放视频时自动垂直滚动文本视图。我的文本太长,无法适应屏幕,我想在活动开始时自动滚动它。我遵循了这里发布的有关堆栈溢出的每个教程或提示,但我无法弄清楚。
这是我的类文件:
public class TextSrcollActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_text_srcoll);
TextView tv=(TextView)findViewById(R.id.textView1);
tv.setMovementMethod(new ScrollingMovementMethod());
tv.setSelected(true);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.text_srcoll, menu);
return true;
}
}
这是我的XML文件:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginRight="3dp"
android:layout_marginTop="3dp"
android:background="#ff737373"
android:gravity="center"
android:minWidth="64dp"
android:orientation="vertical"
android:padding="3dp" >
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:maxWidth="100px"
android:scrollHorizontally="false"
android:scrollbars="vertical"
android:gravity="bottom"
android:singleLine="false"
android:textColor="#ffd9d9d9"
android:textSize="16sp"/>
</LinearLayout>
在XML文件中,我尝试更改某些属性,但仍然没有任何内容。
多行文本视图上的省略号存在问题。这是此处错误报告的一个旧问题:http://code.google.com/p/android/issues/detail?id=2254
在错误报告的底部有一个解决方法,在SO上还有另一个解决方法:android椭圆形多行文本视图
在
滚动视图中使用文本视图。
<ScrollView
android:id="@+id/ScrollView01"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:maxWidth="100px"
android:scrollHorizontally="false"
android:scrollbars="vertical"
android:gravity="bottom"
android:singleLine="false"
android:textColor="#ffd9d9d9"
android:textSize="16sp"/>
</ScrollView>