Android - Linearlayout in ScrollView
-
26-10-2019 - |
Frage
Da meine Benutzeroberfläche ganz einfach ist, möchte ich sowohl Landschaft als auch Porträt in einer XML -Datei sorgen.
Im Porträtmodus ist alles so, wie ich es genau möchte.
In der Landschaft wird die main_title textview kaum gezeigt. Gibt es dafür eine Arbeit?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView android:background="@color/background"
android:layout_width="fill_parent" android:padding="20dip"
android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:layout_height="fill_parent"
android:layout_gravity="center" android:orientation="vertical"
android:layout_marginTop="30dip" android:id="@+id/LinearLayout01"
android:layout_width="fill_parent">
<TextView android:layout_marginBottom="15dip"
android:textSize="24.5sp" android:layout_height="wrap_content"
android:id="@+id/TextView01" android:layout_gravity="center"
android:text="@string/main_title" android:layout_width="wrap_content"></TextView>
<Button android:layout_marginBottom="15dip"
android:layout_height="wrap_content" android:id="@+id/start_button"
android:text="@string/start_label" android:layout_width="fill_parent"></Button>
<TextView android:textSize="18sp" android:layout_height="wrap_content"
android:id="@+id/TextView02" android:text="@string/time_window_please_select_label"
android:layout_width="wrap_content"></TextView>
<Spinner android:layout_height="wrap_content" android:id="@+id/spinner"
android:prompt="@string/time_window_prompt" android:layout_width="fill_parent"></Spinner>
<TextView android:layout_height="wrap_content"
android:layout_marginBottom="10dip" android:id="@+id/status_label"
android:layout_width="wrap_content"></TextView>
<TextView android:layout_height="wrap_content"
android:layout_marginBottom="10dip" android:id="@+id/status_time_label"
android:layout_width="wrap_content">
</TextView>
<ImageView android:layout_marginTop="60dip" android:id="@+id/info_button"
android:src="@drawable/info" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_gravity="bottom|right" />
</LinearLayout>
</ScrollView>
Links:
Lösung
Sieht so aus, als ob das Problem bei Ihrem liegt margin
und padding
Werte.
Die beste Option kann darin bestehen, 2 verschiedene Layouts dafür zu haben, wobei 1 Porträt und andere Landschaftslandschaft sind. Erstellen Sie einen anderen Ordner namens namens layout-land
und layout-port
in deiner res
Mappe. Kopieren Sie dann die Layoutdatei in diese beiden Ordner und nehmen Sie geeignete Änderungen für die Ausrichtung vor.
Weitere Informationen zur Bereitstellung verschiedener Ressourcen für unterschiedliche Orientierungen und so weiter finden Sie in den Android -Dokumenten: http://developer.android.com/guide/topics/resources/providing-resources.html#alternativeresources
Andere Tipps
Fügen Sie oben in der Datei eine leere Textansicht hinzu, dh über dem nicht sichtbaren Textview. Vielleicht ist Ihr Inhaltsbereich sehr groß und der Bildschirm kann ihn nicht unterstützen. Das Problem, mit dem Sie konfrontiert sind, sollte nicht in erster Linie stattfinden ... aber dies ist eine Arbeit. Versuchen Sie auch, Emulatoren zu wechseln ...