2017-02-08 4 views
1

アプリケーションにRecyclerViewのデータを表示させたいのですが、表示される列のサイズが異なります。私はこのことを知らないので、どのようにレイアウトの列サイズを同じにすることができますか?レイアウトレイアウトとレイアウトレイアウトの関係

これは私のコードである:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
    android:layout_margin="10dp" 
    > 
<TableLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:weightSum="9" 

    > 
    <TableRow 
     android:layout_height="wrap_content" 
     android:layout_width="0dp" 
     android:weightSum="9" 
     android:gravity="left" 
     android:background="@drawable/borderc"> 
     <TextView 
      android:id="@+id/namabar" 
      android:layout_weight="2.5" 
      android:text="Nama Barang" 
      android:layout_height="wrap_content" 
      android:maxLength="15" 
      android:gravity="left" 
      android:layout_width="match_parent" 
      android:background="@drawable/borderc" 
      /> 
     <TextView 
      android:layout_weight="2" 
      android:id="@+id/jumlahbar" 
      android:text="Jumlah" 
      android:layout_height="wrap_content" 
      android:background="@drawable/borderc" 
      android:layout_width="match_parent"/> 
     <TextView 
      android:layout_weight="2" 
      android:id="@+id/hargabar" 
      android:layout_height="match_parent" 
      android:background="@drawable/borderc" 
android:text="Harga" 
      android:gravity="left" 
      android:layout_width="match_parent"/> 

     <TextView 
      android:id="@+id/kodebar" 
      android:layout_weight="2.5" 
      android:background="@drawable/borderc" 
android:text="kode" 
      android:gravity="left" 
      android:layout_height="wrap_content" 
      android:layout_width="match_parent"/> 
    </TableRow> 
</TableLayout> 
</LinearLayout> 

enter image description here

答えて

0

それぞれのTextViewが等しい量を有するべきである= 1

それぞれのTextViewレイアウト幅= 0dp

重量和

を除去有していなければなりません
+0

とおそらく? –

+1

私の編集を参照してください、おそらく何も意味はありません – seekingStillness

+0

はい、それは働いて、ありがとうございます。 –

0

削除するandroid:weightSum="9"からTableLayoutまで、そしてTableRowから。 TableLayoutの中にandroid:stretchColumns="*"を追加します。

関連する問題