Chcę stworzyć układ ekranu Androida, który wygląda mniej więcej tak:
Label Text Field
Label Text Field
Label Text Field
-----Button-------
-----TextField----
Oznacza to, że chcę mieć TableLayout na górze, z kilkoma elementami pod układem tabeli (głównie po to, abym mógł wymusić, aby te elementy znajdowały się na dole ekranu). Próbowałem zagnieździć je jak w poniższym kodzie, ale elementy na dole wydają się nie pojawiać.
Jakieś pomysły?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:stretchColumns="1"
android:shrinkColumns="1" android:layout_height="wrap_content" android:layout_gravity="center_vertical">
<TableRow>
<TextView android:text="Latitude:"
android:textAppearance="?android:attr/textAppearanceLarge"
/>
<TextView android:id="@+id/latitude"
android:text="Not available"
android:textAppearance="?android:attr/textAppearanceLarge"
/>
</TableRow>
<TableRow>
<TextView android:text="Longitude:"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<TextView android:id="@+id/longitude"
android:text="Not available"
android:textAppearance="?android:attr/textAppearanceLarge"/>
</TableRow>
<TableRow>
<TextView android:text="Altitude:"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<TextView android:id="@+id/altitude"
android:text="Not available"
android:textAppearance="?android:attr/textAppearanceLarge"/>
</TableRow>
<TableRow>
<TextView android:text="Accuracy:"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<TextView android:id="@+id/accuracy"
android:text="Not available"
android:textAppearance="?android:attr/textAppearanceLarge"/>
</TableRow>
</TableLayout>
<Button android:id="@+id/save"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Save"/>
<TextView android:text="Test"/>
</LinearLayout>
3 odpowiedzi
W układzie tabeli dodaj je
android:layout_height="80dp"
android:layout_weight="1.0"
Również dla dolnego przycisku i widoku tekstu dodaj stałą wysokość. Jeśli Twój stół potrzebuje więcej miejsca, umieść go między scrollView
Ustaw wagę stołu na „1”, a wysokość na „0dp”.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:shrinkColumns="1"
android:stretchColumns="1" >
<TableRow>
...
</TableRow>
</TableLayout>
<Button
android:id="@+id/save"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Save" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Test" />
</LinearLayout>
Dla pola tekstowego musisz użyć EditText zamiast TextView i dodać android:layout_height
i android:layout_width
do każdego widżetu używanego w twojej aplikacji.
Podobne pytania
Nowe pytania
android
Android to mobilny system operacyjny Google, używany do programowania lub tworzenia urządzeń cyfrowych (smartfony, tablety, samochody, telewizory, Wear, Glass, IoT). W przypadku tematów związanych z Androidem użyj tagów specyficznych dla Androida, takich jak android-intent, android-activity, android-adapter itp. W przypadku pytań innych niż programowanie lub programowanie, ale związanych ze strukturą Androida, użyj tego linku: https: // android.stackexchange.com.