Probleme beim Verständnis von Android XML layout_weight
Ich habe wirklich versucht, aber ich kann nicht verstehen, wie Android interpretiertlayout_weight
setting ...
Was ich versuche zu erreichen, ist
ein Header oben mit einer festen Höhe Ein Eingabebereich am unteren Rand mit einem EditText und einem Buttona Inhaltsteil in der Mitte, der alle Reste des Platzes einnimmtBei der Eingabe möchte ich den EditText auf eine bestimmte Höhe vergrößern und mit dem Scrollen beginnen, wenn der eingegebene Text die verfügbare Höhe überschreitet. Dazu brauche ich die UmgebungLinearLayout
um mit dem EditText zusammen zu wachsen.
Wenn ich eine bestimmte Höhe für das innere @ definieLinearLayout
es wird nicht wachsen. Wenn ich das nicht tue, nimmt das innere Layout anstelle der ScrollView den gesamten Platz ein, unabhängig davon, was ich mit @ versuchlayout_weight
. :
Meine aktuelle XML sieht so aus:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="I'm a header" />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="bottom">
<LinearLayout
android:id="@+id/itemContainer"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</ScrollView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="50dp"
android:padding="2dp"
android:gravity="bottom"
android:isScrollContainer="true"
android:background="@drawable/steel" >
<EditText
android:id="@+id/edittext01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:scrollbars="vertical"
android:fadingEdge="vertical"
android:fadingEdgeLength="60dp"
android:maxHeight="40dp"
android:textSize="15sp" />
<Button
android:id="@+id/button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:layout_gravity="right"
android:text="Send"
android:textStyle="bold"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>
Alle Tipps sind sehr dankbar!