【发布时间】:2025-12-24 22:50:11
【问题描述】:
我正在尝试在播放视频时垂直自动滚动文本视图。我的文本太长,无法适应屏幕,我想在活动开始时自动滚动它。我按照堆栈溢出此处发布的每个教程或提示进行操作,但我无法弄清楚。
这是我的类文件:
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 文件中,我尝试更改一些属性,但我仍然没有。
【问题讨论】:
标签: android scroll textview marquee