Mam układ podobny do kalkulatora, 4 przyciski w każdym rzędzie, z 5 rzędami. Stworzyłem te wiersze, używając LinearLayout
. Udało mi się całkowicie wypełnić szerokość każdego wiersza, używając android:layout_weight="1"
w każdym przycisku w LinearLayout
. Ale nie wiem, jak wypełnić przestrzeń pionową w ten sposób. Po pięciu rzędach istnieje przestrzeń pozostała na dnie dla zwykłych ekranów XDPI (Nexus 4)Jak równomiernie rozłożyć przyciski/układy w pionie w systemie Android?
<LinearLayout
android:id="@+id/first_row"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/entry">
<Button
android:id="@+id/seven"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="7"
android:textColor="@color/Blue_ICS"
android:textSize="@dimen/button_text_size"
/>
<Button
android:id="@+id/eight"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="8"
android:textColor="@color/Blue_ICS"
android:textSize="@dimen/button_text_size"/>
<Button
android:id="@+id/nine"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="9"
android:textColor="@color/Blue_ICS"
android:textSize="@dimen/button_text_size"/>
<Button
android:id="@+id/plus"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="+"
android:textColor="@color/Blue_ICS"
android:textSize="@dimen/button_text_size"/>
</LinearLayout>
Układ jest zbyt długi, więc dzielę się tutaj kod tylko z pierwszego rzędu, pozostałe wiersze są takie same też.
Czy chcesz wypełnić swoje wiersze równą wysokością? –
Czy próbowałeś zmienić atrybut wysokości 'LinearLayout' ?:' android: layout_height = "match_parent" ' –
check out [this link] (http://stackoverflow.com/a/8105131/2345913) – CRUSADER