I have a layout that looks as follows:
|User Name | |
|email@mail.com | info |
And I need to set user's first name and second name if it fits into TextView and only first name if first name and second name is too long for current screen.
For example for "Tom Smith":
|Tom Smith | |
|email@mail.com | info |
and for "Tom VeryVeryVeryLongSurname":
|Tom | |
|email@mail.com | info |
How can I get a name size with specified text size and compare it with TextView width?
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<TextView
android:id="@+id/info"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="bottom"/>
</LinearLayout>