我正在尝试实现在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样式。
发布于 2012-08-19 22:52:26
请使用下面的代码。
<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);
https://stackoverflow.com/questions/12033109
复制相似问题