<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="2dp"
android:layout_marginLeft="10dp"
android:text="Don't worry we will never share this with anyone\nBy Clicking register you are indicating that you have read and agreed to the \n **Terms of services** and **Privacy Policy**"
android:textColor="@android:color/black"
android:textSize="8.5sp"
/>从上面的代码中,我需要在服务条款和隐私政策下划线,这些条款和隐私政策以粗体突出显示。
我试过使用<u></u>,但不起作用。
我还需要增加服务条款的字体,仅隐私政策
请一定要给我一些建议。
发布于 2013-02-12 18:14:53
你需要在strings.xml file.Yes中定义你的文本,你也可以在其中定义格式化的html。
所以你可以试试这个:
<string name="nice_html">
<![CDATA[Don't worry we will never share this with anyone<br/>
By Clicking register you are indicating that you have read and agreed to the <br/>
<u>Terms of services</u> and <u>Privacy Policy</u>
]]></string>然后,在你的代码中:
TextView foo = (TextView)findViewById(R.id.foo); foo.setText(Html.fromHtml(getString(R.string.nice_html)));
这是做it.Inshallah最干净的方法。
发布于 2013-02-12 18:12:13
String mString=new String("Don't worry we will never share this with anyone\nBy Clicking register you are indicating that you have read and agreed to the \n **Terms of services** and **Privacy Policy**");
SpannableString span = new SpannableString(mString);
span.setSpan(new UnderlineSpan(), index of T in terms, mString.length(), 0);
mTextView.setText(span);https://stackoverflow.com/questions/14829942
复制相似问题