当testView的长度超过屏幕宽度时,我使用此代码进行自动滚动: -
<TextView
android:id="@+id/tViewWork"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="center_vertical"
android:marqueeRepeatLimit="marquee_forever"
android:padding="3dp"
android:scrollHorizontally="true"
android:selectAllOnFocus="true"
android:singleLine="true"
android:text="Name of work: "
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#dedfdc"
android:textStyle="bold" />
我想滚动没有三个点的字符。上面的代码滚动字符,但最后显示三个点。
答案 0 :(得分:0)
试试这个,将以下属性添加到TextView
。您在xml中缺少android:ellipsize="marquee"
属性
android:ellipsize="marquee"
android:focusable="true"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"
并且还在java代码中为您TextView
设置了选定的true
TextView tViewWork = (TextView) findViewById(R.id.tViewWork);
tViewWork.setSelected(true);
答案 1 :(得分:0)
尝试以下代码:
<TextView android:id="@+id/fact" android:layout_width="200dp"
android:text="Loading... More text to see if it spans or not and want more"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit ="marquee_forever"
android:scrollHorizontally="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:duplicateParentState="true">
<requestFocus android:focusable="true" android:focusableInTouchMode="true"
android:duplicateParentState="true" />
答案 2 :(得分:-1)
除去
android:singleLine =“true”它将自动获取所需的宽度和高度