-1

Is it possible to split a textView into multiple rows and have a style for each row?

for example i would like to have in a textview:

" Row1 //color black and bold

Row2 //different font and color"

this is my layout xml

   <?xml version="1.0" encoding="utf-8"?>
  <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF">
  <TextView
    android:id="@+id/name"
    android:text="Name"
    android:paddingLeft="10dip"
    android:layout_weight="0.5"
    android:layout_gravity="center"
    android:layout_width="wrap_content"
      android:layout_height="wrap_content"
    android:textColor="#000000" />
  </LinearLayout>

I'm setting the text view s text with :

      textView.setText("Row1 /n Row2");

Is it possible to ad a table inside the textView and change each row's style?

How can i do this?

Thank you!

Dan Dinu
  • 32,492
  • 24
  • 78
  • 114
  • You should use multiple TextViews for this purpose. – Egor Sep 02 '12 at 12:37
  • possible duplicate of [Is it possible to have multiple styles inside a TextView?](http://stackoverflow.com/questions/1529068/is-it-possible-to-have-multiple-styles-inside-a-textview) – bigstones Sep 02 '12 at 12:41

1 Answers1

1

You can use Html.fromhtml() to add different colors and fonts to text and to add another line in TextView simply use "\n"

Example: textview.setText("text1"+"\n"+"text2")

Example for Html.fromhtml(): text.setText(Html.fromHtml("<font color='#ff0000'>text</font>"));

Abhi
  • 8,935
  • 7
  • 37
  • 60