2017-02-08 6 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

= 1 각 텍스트 뷰가 있어야

레이아웃 폭 = 0dp

중량 합

삭제
+0

그리고 아마도? –

+1

내 편집을 참조하십시오. 아마도 아무 의미도 없습니다. – seekingStillness

+0

예, 작동합니다. 감사합니다. –

0

삭제 android:weightSum="9"TableLayout이고, 처음에는 TableRow이다. 이제 TableLayout 안에 android:stretchColumns="*"을 추가하십시오.