lassen Sie scrollview füllen Sie den ganzen Bildschirm, außer für die Höhe des relative layout am unteren Rand des Bildschirms
Ich bin stecken, wie Sie füllen den ganzen Bildschirm mit einem top-layout mit Ausnahme der benötigte Platz für eine bottom-layout. Ich bin mit relativ layouts platzieren des layouts, aber ich möchte, dass meine Ansicht von oben, dass der gesamte Raum mit Ausnahme der Raum brauchte für meine Ansicht von unten (die Ansicht von oben Höhe ändert sich je nach user-input). Siehe xml-unten. Jetzt, meine top-Ansicht wird nur so viel Speicherplatz wie das linearlayout innerhalb der scrollview braucht + der Raum, der myTopButton nimmt.
XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg"
android:paddingBottom="10dip"
android:focusable="true"
android:focusableInTouchMode="true">
<RelativeLayout android:id="@+id/topLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="80dip"
android:layout_alignParentTop="true">
<ScrollView android:id="@+id/myscroll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginBottom="65dip"
android:paddingRight="2dip"
android:paddingLeft="6dip"
android:fillViewport="true">
<LinearLayout style="@style/LinearLayoutInner"
android:orientation="vertical">
</LinearLayout>
</ScrollView>
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<Button android:id="@+id/search"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dip"
android:text="@string/search_viewdoses"/>
</LinearLayout>
</RelativeLayout>
<RelativeLayout android:id="@+id/bottomLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="-60dip"
android:layout_alignParentBottom="true">
<TextView android:id="@+id/myText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="@string/mytext"></TextView>
<EditText android:id="@+id/myEdit"
android:layout_width="80dip"
android:layout_height="50dip"
android:layout_alignParentBottom="true"
android:layout_toRightOf="@+id/myText"
android:singleLine="true"
android:inputType="numberDecimal"></EditText>
<Button android:id="@+id/save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="10dip"
android:text="@string/mybuttontext"/>
</RelativeLayout>
</RelativeLayout>
BILDSCHIRM JETZT:
BILDSCHIRM WOLLTE:
- Sie können die
android:fillViewport
- Flagge auf derScrollView
um es zu zwingen, nicht wickeln Sie die Höhe auf Ihre Inhalte - probieren. - Ich habe bereits android:fillViewport zu wahr, fürchte ich.
- Sorry, habe ich völlig übersehen! Ich habe bemerkt, dass man sich die Einstellung eines unteren Rand auf die
ScrollView
(android:layout_marginBottom="65dip"
) - ist das nicht einfach, sodass die Blaue Lücke zwischen den rot-und grün-layouts?
Du musst angemeldet sein, um einen Kommentar abzugeben.
Entfernen Sie einfach den unteren Rand von
topLayout
und fügen Sieandroid:layout_above="@+d/bottomLayout"
zu. Sie haben zu definieren, diebottomLayout
vortopLayout
in Ihrer xml-obwohl. Ich denke, man sollte auch entfernen Sie den oberen Rand von IhrembottomLayout
.Gleiche gilt für die eigentliche scrollView und die Taste.
Versuchen Sie
android:layout_weight="1"
auf der ScrollView.In der layout-tag
entfernen Sie einfach
android:layout_marginBottom="80dip"
und Sie sollten bereit sein zu gehen. Es ist der, den man produziert, dass hässliche, unerwünschte Raum an der Unterseite des oberen.