Ich füge TextView
in eine LinearLayout
, aber diese LinearLayout
erweitert, wenn ich es mit Text (TextView
) füllen. Es ist keine Option, es zu RelativeLayout
oder etwas in der Art zu ändern, weil ich einem Führer von einem Buch folge. Das ist mein XML-Code:LinearLayout erweitert beim Hinzufügen von 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 weil Eltern mit wrap_content passt sich an die Child-Breite an (die größte unter seinem Kind). –
Was ist das normale Verhalten einer Ansichtsgruppe (wie Linearlayout)? Aber was ist deine Frage? Willst du ein anderes Verhalten? – Dibzmania