0

Ich möchte ein tablelayout mit 3 Zeilen und 4 Spalten haben.Android Tabellenlayout letzte Zeile kleiner

Die ersten beiden Reihen sind in Ordnung, aber die letzte ist viel zu klein als die anderen.

Ich versuchte es mit einem 5,5 Bildschirmgröße Telefon (Samsung Galaxy Note 2), wo die Zeilen sind fast gleich hoch, aber auf einem 9,6 Zoll Tablet (Samsung Galaxy Tab E), ist die letzte Reihe sehr klein. Was mache ich falsch?

Ich habe auch meine Layout-Datei und einen Screenshot mit dem tatsächlichen Layout beigefügt.

Mein Code:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/activity_main" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/domestic" 
    android:orientation="vertical"> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:layout_margin="5sp" 
     android:gravity="center" 
     android:background="@drawable/rounded_corner_start"> 

     <TableLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:measureWithLargestChild="true" 
      android:stretchColumns="*"> 

      <!-- Row with 4 columns --> 
      <TableRow 
       android:layout_height="0dp" 
       android:layout_width="match_parent" 
       android:layout_weight="1"> 
       <!--Kutya--> 
       <LinearLayout 
        android:id="@+id/lnDog" 
        android:layout_width="0dp" 
        android:layout_height="fill_parent" 
        android:layout_margin="3sp" 
        android:orientation="vertical" 
        android:background="@drawable/rounded_corner_elements" 
        android:layout_weight="1"> 
        <ImageView 
         android:layout_width="match_parent" 
         android:layout_height="0dp" 
         android:layout_weight="0.8" 
         android:src="@drawable/dog"/> 
        <TextView 
         android:layout_width="match_parent" 
         android:layout_height="0dp" 
         android:fontFamily="sans-serif-thin|bold" 
         android:text="@string/dog" 
         android:gravity="center" 
         android:layout_weight="0.2" /> 
       </LinearLayout> 
       <!--Macska--> 
       <LinearLayout 
        android:id="@+id/lnCat" 
        android:layout_width="0dp" 
        android:layout_height="fill_parent" 
        android:layout_margin="3sp" 
        android:orientation="vertical" 
        android:background="@drawable/rounded_corner_elements" 
        android:layout_weight="1"> 
        <ImageView 
         android:layout_width="match_parent" 
         android:layout_height="0dp" 
         android:layout_weight="0.8" 
         android:src="@drawable/cat2"/> 
        <TextView 
         android:layout_width="match_parent" 
         android:layout_height="0dp" 
         android:fontFamily="sans-serif-thin|bold" 
         android:text="@string/cat" 
         android:gravity="center" 
         android:layout_weight="0.2" /> 
       </LinearLayout> 
       <!--Diszno--> 
       <LinearLayout 
        android:id="@+id/lnPig" 
        android:layout_width="0dp" 
        android:layout_margin="3sp" 
        android:layout_height="fill_parent" 
        android:orientation="vertical" 
        android:background="@drawable/rounded_corner_elements" 
        android:layout_weight="1"> 
        <ImageView 
         android:layout_width="match_parent" 
         android:layout_height="0dp" 
         android:layout_weight="0.8" 
         android:src="@drawable/pig"/> 
        <TextView 
         android:layout_width="match_parent" 
         android:layout_height="0dp" 
         android:fontFamily="sans-serif-thin|bold" 
         android:text="@string/pig" 
         android:gravity="center" 
         android:layout_weight="0.2" /> 
       </LinearLayout> 
       <!--Tyuk--> 
       <LinearLayout 
        android:id="@+id/lnChicken" 
        android:layout_width="0dp" 
        android:layout_margin="3sp" 
        android:layout_height="fill_parent" 
        android:orientation="vertical" 
        android:background="@drawable/rounded_corner_elements" 
        android:layout_weight="1"> 
        <ImageView 
         android:layout_width="match_parent" 
         android:layout_height="0dp" 
         android:layout_weight="0.8" 
         android:src="@drawable/chicken"/> 
        <TextView 
         android:layout_width="match_parent" 
         android:layout_height="0dp" 
         android:fontFamily="sans-serif-thin|bold" 
         android:text="@string/chicken" 
         android:gravity="center" 
         android:layout_weight="0.2" /> 
       </LinearLayout> 
      </TableRow> 
      .... 
      4 times 
     </TableLayout> 
    </LinearLayout> 
</LinearLayout> 

9.6 inch tablet

Antwort

0

So, endlich habe ich es hin, dass alle Bilder die gleiche Höhe haben sollte, und dann alle Zeilen haben die gleiche Höhe. Es ist merkwürdig, denn ich hätte erwartet, dass sich der innere Inhalt automatisch anpassen würde, wenn man das Gewicht der Tabelle festlegt.