0
<TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="2dp"
        android:layout_marginLeft="10dp"
        android:text="Don&apos;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>但没有奏效。

另外我需要增加服务条款的字体,仅隐私政策

请给一些建议。

4

2 回答 2

1

您需要在文件中定义文本。是的strings.xml,您也可以在其中定义格式化的 html。

所以你可以试试这个:

<string name="nice_html">
<![CDATA[Don&apos;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)));

原始答案

这是最干净的方法。Inshallah。

于 2013-02-12T10:14:52.710 回答
0
String mString=new String("Don&apos;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);
于 2013-02-12T10:12:12.963 回答