Я добавляю TextView
в LinearLayout
, но этот LinearLayout
расширяется, когда я заполняю его текстом (TextView
). Это не вариант, чтобы изменить его на RelativeLayout
или что-то в этом роде, потому что я следую руководству из книги. Это мой XML-код:LinearLayout расширяется при добавлении TextView
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="40"
android:background="@android:color/holo_orange_light">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<TextView
android:text=""
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/textView" />
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="60">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srcCompat="@mipmap/ic_launcher"
android:id="@+id/imageView"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
Ofcourse потому, что родитель с wrap_content будет регулировать его ширину для ребенка (наибольшую из ее дочерних элементов). –
Что вы видите, это нормальное поведение группы вида (например, Linearlayout). Но каков ваш вопрос? Вам нужно другое поведение? – Dibzmania