Android 文本视图选框不滚动
我花了几个小时试着用谷歌搜索。我看过其他的帖子,但没有任何效果。 我确实有电视;在我的代码中 ` ` 这是我的文本视图Android 文本视图选框不滚动,android,marquee,Android,Marquee,我花了几个小时试着用谷歌搜索。我看过其他的帖子,但没有任何效果。 我确实有电视;在我的代码中 ` ` 这是我的文本视图 <TextView android:id="@+id/tv" android:layout_width="wrap_content" android:layout_height="match_parent" android:ellipsize="marquee" android:focusable="true" androi
<TextView
android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:freezesText="true"
android:marqueeRepeatLimit="marquee_forever"
android:paddingLeft="15dip"
android:paddingRight="15dip"
android:scrollHorizontally="true"
android:singleLine="true"
android:textSize="30sp" />
将下面的[tv.setSelected(true);]放置到setContentView(R.layout.activity_main)中
在xml中
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text=""
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true" />
只需在OnCreate方法中这样做即可
yourTextView= (TextView) findViewById(R.id.yourTextViewID);
yourTextView.setSelected(true);
yourTextView.setEllipsize(TruncateAt.MARQUEE);
yourTextView.setSingleLine(true);
您是否在设备或模拟器上进行过测试?
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text=""
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true" />
yourTextView= (TextView) findViewById(R.id.yourTextViewID);
yourTextView.setSelected(true);
yourTextView.setEllipsize(TruncateAt.MARQUEE);
yourTextView.setSingleLine(true);