0

段落のタイトルを斜体(可能であれば太字)に設定しようとしていますが、喜びがありません。これは私がこれまでに持っているものです:

...sound and active.\n\n HEAD \n The skull is broad and...

ですから、私がやりたいのは、「HEAD」を斜体と太字に設定することです。

完全なコード:

FlowTextView tv1 = (FlowTextView) findViewById(R.id.tv4);              
    Spanned spannable1 = Html.fromHtml("<html ... </html>");
    tv1.setText(spannable1);  // using html
    tv1.setText("...sound and active.\n\n HEAD \n The skull is broad and....   
    tv1.setTextSize(20);
    tv1.invalidate(); 

誰か助けてもらえますか?

4

5 に答える 5

1

次のようにしてみてください:

   FlowTextView tv1 = (FlowTextView) findViewById(R.id.tv4);              
        Spanned spannable1 = Html.fromHtml("<html ... </html>");
     tv1.setText(spannable1);  // using html
     tv1.setText(Html.fromHtml("...sound and active.\n\n <b> <i>HEAD </i></b> \n 
                                           The skull is broad and....   "));
        tv1.setTextSize(20);
        tv1.invalidate(); 
于 2012-12-19T11:09:44.330 に答える
0

strings.xmlこのように、必要な属性を使用してテキストを作成します

<string name="text">This is <b><i> StackOverflow </i></b></string>

このようなアクティビティでこの文字列を呼び出します

tv.settext(R.string.text);
于 2012-12-19T11:12:13.220 に答える
0

このコードを試す

Strings.xml

    <string name="text"> <b> Head </b> \n\n The skull is broad and </string>

Main.xml

 <TextView
       android:id="@+id/textView1"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:text="@string/text"
       android:textSize="16dp" />
于 2012-12-19T11:13:41.317 に答える
0

android:textStyle="italic"textViewタグで使用してみてください。それはうまくいくでしょう。

于 2012-12-19T11:23:20.783 に答える
0

このように使用できます。TextViewtv=new TextView(this); tv.setTypeface(null、Typeface.ITALIC);

于 2012-12-19T11:53:14.457 に答える