我正在尝试实现字幕样式以在android中打印字符串。我可以使用静态数据,但对于动态数据,它不显示选取框样式。
当我打印时:
String st="this is test application testing for marquee"
我得到了字幕风格。
但是,在解析后,当我获取数据时:
<TextView
android:id="@+id/twxmorq"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:padding="5dip"
android:scrollHorizontally="true"
android:singleLine="true"
android:textColor="#FF0000" />
我跑:
myString = myString + "| "+ json_data.getString("news_title").toString();
txt1 = (TextView) findViewById(R.id.twxmorq);
txt1.setText(myString1);
并且当我打印
mystring
时,我看不到字幕样式。请帮我。
摘要:对于字符串'ST',我得到的是字幕样式的打印字符串,但是对于
mystring1
我没有的是marequee样式。 最佳答案
为此使用下面的代码。
<TextView
android:id="@+id/twxmorq"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:padding="5dip"
android:scrollHorizontally="true"
android:singleLine="true"
ndroid:lines="1"
android:textColor="#FF0000"
android:fadingEdge="horizontal"/>
Java代码:
myString = myString + "| "+ json_data.getString("news_title").toString();
txt1 = (TextView) findViewById(R.id.twxmorq);
txt1.setSelected(true);
txt1.setText(myString1);