0

I have a TextView in RelativeLayout in which I am setting the text from a string and that string contains the text more than 2 lines. But I want to set the Text into two lines. All is working but the problem is the Text in two lines is not aligned well.

Here is how it looks:

This is the text of first line which contains a dummy text

As you can see I have set left margin of 5 then it only applied on first line but not on the second one. So what is the problem and how can I solve it?

<TextView
    android:id="@+id/message"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_toLeftOf="@+id/image"
    android:maxLines="2"
    android:layout_marginLeft="10dp"
    android:textSize="20sp"
    android:textColor="#000000"
    android:textAppearance="?android:attr/textAppearanceMedium">
</TextView>
Vamshi
  • 1,495
  • 1
  • 15
  • 31
Abid Khan
  • 2,451
  • 4
  • 22
  • 45
  • But your text is in one line, edit your question to show how exactly you want. – Spring Breaker Apr 23 '14 at 05:22
  • http://stackoverflow.com/questions/16890153/how-to-know-which-phone-support-which-layouthdpi-mdpi-and-xhpi – duggu Apr 23 '14 at 05:23
  • In your string.xml file you have to include "\n" wherever you want so the after that the next text will display in next line. – Born To Win Apr 23 '14 at 05:25
  • post a screen shot. also set textsize for your textview. Also remove android:layout_alignParentLeft="true" because your textview is in relative layout and LeftOf="@+id/image". – Amrut Apr 23 '14 at 07:01

0 Answers0