Hallo, ich bin ein bisschen Stumpf jetzt. Ich dachte, das ist in Android XML möglich.Machen Sie Ansicht füllen Sie die Lücke in der Mitte, aber hinterlässt Platz zu seinen unteren Geschwister
Ich wollte ein Layout wie diese machen:
Das Problem ist, die kleinen zwei Elemente, die nebeneinander sind. Wenn ich die Ansicht Nr. 2 an die Höhe anpasse, erwarte ich, dass sie auch den Platz ihrer anderen Geschwister respektiert. Ich lag falsch, aber ich verstehe es jetzt. Wenn ich die layout_Height der Ansicht # 2 auf "match_parent" einstelle, belegt sie den verbleibenden Platz und die Ansicht # 3 und die Ansicht # 4 werden in den untersten Teil gelegt und sind auf dem Bildschirm nicht mehr sichtbar.
Ich möchte, dass Ansicht # 2 in der Mitte erweitert wird, aber immer noch Platz für Ansicht # 3 und Ansicht # 4 und einige Elemente darunter und nicht weit nach unten geschoben werden. Hier
ist, was ich jetzt tue:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:fitsSystemWindows="true"
tools:context=".TaskActivity">
<android.support.design.widget.TextInputLayout
android:id="@+id/textinput_layout_note_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="16dp">
<EditText
android:id="@+id/edittext_task"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:singleLine="true"
android:textSize="32sp"
android:padding="8dp"
android:hint="@string/edittext_task_title_hint"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/textinput_layout_note_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/textinput_layout_note_title">
<EditText
android:id="@+id/edittext_todo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:maxLines="1"
android:gravity="top"
android:hint="@string/edittext_task_content_hint"/>
</android.support.design.widget.TextInputLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/textinput_layout_note_description"
android:orientation="horizontal">
<ImageButton
android:id="@+id/imagebutton_insert_note"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_content_add_black"
android:contentDescription="@string/content_description_choose_note"
style="?android:attr/borderlessButtonStyle" />
<ImageButton
android:id="@+id/imagebutton_expand_note"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_open_in_new_black_24dp"
android:contentDescription="@string/content_description_expand_note"
style="?android:attr/borderlessButtonStyle" />
</LinearLayout>
</RelativeLayout>
ich verwendet habe, mit Linearlayout layout_weight kombiniert, aber das wird immer langsamer, als ich einige verschachtelte Ansichten haben, die auch Gewicht erfordert. Ich wollte, dass das relativ gemacht wird.
Irgendwelche Ideen, wie ich dieses Layout erreichen kann?
Vielen Dank!
Hallo @CommonsWare, was ist, wenn ich andere Ansichten direkt unter Ansicht 3 und 4 habe. Ich habe meine in letzter Zeit versucht, aber habe es nicht zur Arbeit. Der beste Weg, über den ich nachdenken könnte, ist, alles in zwei Teilen durch ein lineares Layout zu trennen. Aber ich bin fasziniert, wenn dies für RelativeLayout überhaupt möglich ist? –
@NeonWarge: Aus dem Stegreif, haben diese 'android: layout_alignParentBottom =" true "'.Habe das 'LinearLayout', das ich als' whatever_this_thing_is' identifiziert habe, 'android: layout_above', das neue Zeug. Alles andere würde so bleiben wie es ist. – CommonsWare