1

My problem seems apparently simple, but I have not been able to find a solution.

I have 2 TextViews, they have the SAME TEXT but have

  • different size of TextView;
  • different size of the font of the text inside the TextView.

I HAVE NO CONTROL OVER THE TEXT (it comes from remote).

I wish to have the 2 TextViews to have the line break exactly at the same point

enter image description here

Lisa Anne
  • 4,482
  • 17
  • 83
  • 157

2 Answers2

1

Place a text to one of the TextViews and then use the text inside as a source for the second text view using:

Detect where Android's TextView would insert a line break

The second text view should have a little more "width capacity" to be able to place everything what is in the first view without making its "own" line breaks.

Community
  • 1
  • 1
Quark
  • 1,578
  • 2
  • 19
  • 34
0

Specify the max length of characters in one line of both the textViews. This can be done by using a property for the TextViews in the layout where they are defined:

<TextView
        android:id="@+id/textViewName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="20dp"
        android:layout_marginTop="20dp"
        android:gravity="center"
        android:maxLength="12" />
kamal2305
  • 671
  • 4
  • 11
  • Thanks kamal2305 but that will not work:-(( : since the TextViews have different dimensions and different characters size it's impossible to determine the ideal lenght. Additionally `maxLength` it's a dimension (in px or dp) not the number of characters – Lisa Anne Mar 21 '15 at 18:29
  • Please follow the link: http://developer.android.com/reference/android/widget/TextView.html#attr_android:maxLength – kamal2305 Mar 22 '15 at 12:11