2

問題に直面しています。メイン画面にアイコンのグリッドを作成したいので、それぞれに 4TableRowsと 3を使用TextViewsしています。はTextViewsアイコンとテキストで構成されており、テキストの長さが異なります。

xmlそれらすべてをTextViews同じ幅で連続させるためにファイルに何を書くべきかわかりません。サイズを表示したlogcatので、同じ幅ではないと確信しています ;)

m1shk4の解決策を試しましたが、うまくいきません。

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clickable="true" >

    <TableRow
        android:id="@+id/tableRow1"
        android:layout_weight="1"
        android:gravity="center" >

            <TextView
                android:id="@+id/textView1"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:layout_width="match_parent"
                android:clickable="true"
                android:drawableTop="@drawable/nearby"
                android:gravity="center"
                android:onClick="goToArticles"
                android:text="All Nearby" />

            <TextView
                android:id="@+id/textView2"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:clickable="true"
                android:layout_width="match_parent"
                android:drawableTop="@drawable/supermarket"
                android:gravity="center"
                android:onClick="goToMap"
                android:text="Supermarkets" />

            <TextView
                android:id="@+id/textView3"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:layout_width="match_parent"
                android:drawableTop="@drawable/pharmacy"
                android:gravity="center"
                android:text="Pharmacy" />

    </TableRow>

   <TableRow
        android:id="@+id/tableRow2"
        android:layout_weight="1"
        android:gravity="center" >

            <TextView
                android:id="@+id/textView4"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:layout_width="match_parent"
                android:drawableTop="@drawable/fastfood"
                android:gravity="center"
                android:text="Fastfood" />

            <TextView
                android:id="@+id/textView5"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:clickable="true"
                android:drawableTop="@drawable/departmentstores"
                android:gravity="center"
                android:onClick="displaySizes"
                android:text="Department Stores" />

            <TextView
                android:id="@+id/textView6"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:layout_width="match_parent"
                android:drawableTop="@drawable/petrol"
                android:gravity="center"
                android:text="Petrol Stations" />

    </TableRow>

    <TableRow
        android:id="@+id/tableRow3"
        android:layout_weight="1"
        android:gravity="center" >

            <TextView
                android:id="@+id/textView7"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:drawableTop="@drawable/electronics"
                android:gravity="center"
                android:layout_width="match_parent"
                android:text="Electronics" />

            <TextView
                android:id="@+id/textView8"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:layout_width="match_parent"
                android:drawableTop="@drawable/diy"
                android:gravity="center"
                android:text="DIY Stores" />

            <TextView
                android:id="@+id/textView9"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:layout_width="match_parent"
                android:drawableTop="@drawable/banking"
                android:gravity="center"
                android:text="Banks" />

    </TableRow>

    <TableRow
        android:id="@+id/tableRow4"
        android:layout_weight="1"
        android:gravity="center" >

            <TextView
                android:id="@+id/textView10"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:layout_width="match_parent"
                android:drawableTop="@drawable/fashion"
                android:gravity="center"
                android:text="Fashion &amp; Clothing" />

            <TextView
                android:id="@+id/textView11"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:layout_width="match_parent"
                android:drawableTop="@drawable/autoparts"
                android:gravity="center"
                android:text="Auto Service" />

            <TextView
                android:id="@+id/textView12"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:layout_width="match_parent"
                android:drawableTop="@drawable/more"
                android:gravity="center"
                android:text="All Categories" />

    </TableRow>

</TableLayout>

何か案が?ありがとう :)

4

1 に答える 1