Есть layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Текст1 Текст1 Текст1 Текст1"
android:maxWidth="280dp"
android:textSize="22dp"/>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Текст2 Текст2"
android:textSize="20dp"/>
</LinearLayout>
Вот как он выглядит:
textView1
занимает больше места, чем ему необходимо (есть свободное пространство справа) и textView2
точно не поместится в одну сточку, хотя мог бы попробовать. Как указать textView1
, чтобы занимал ширину, только которую использует?
UPD
Вот как должен выглядеть экран, если textView1
занимает немного места, поэтому использование android:layout_weight
не выйдет для различных плотностей экранов: