2012-05-14 5 views
0

두 개의 열이있는 TableLayout이 있습니다. 왼쪽 열의 텍스트 및 오른쪽의 CheckBox CheckBox는 내가 생각한대로 중력에 반응하지 않습니다. 그것은 화면 오른쪽에서 15dp 패딩을 뺀 것입니다. 그것을 "패딩 (padding)"하여 우회전하지 못하게합니다.CheckBox를 사용하여 TableLayout을 열의 한쪽으로 이동

그 외에도, 이것은 내가 원하는 것처럼 보입니다.

이렇게하는 것이 가장 효율적인 방법입니까?

CheckBox를 어떻게 푸시 할 수 있습니까?

[재미] [1] TableLayout을위한

<?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="fill_parent" 
    android:background="#FFFFFF" 
    android:padding="15dp" 
    android:weightSum="100" > 

    <TableRow> 

     <TextView 
      android:id="@+id/textView1" 
      android:layout_weight="75" 
      android:text="Label textbox here" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:textColor="#000000" /> 

     <EditText 
      android:id="@+id/editText1" 
      android:layout_weight="25" 
      android:hint="0.00" 
      android:textColor="#000000" > 
     </EditText> 
    </TableRow> 

    <TableRow> 

     <TextView 
      android:id="@+id/textView1" 
      android:layout_weight="80" 
      android:text="Touch for option 2" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:textColor="#000000" /> 

     <CheckBox 
      android:id="@+id/checkBox1" 
      android:layout_weight="20" 
      android:textColor="#000000" /> 
    </TableRow> 

    <TableRow> 

     <TextView 
      android:id="@+id/textView1" 
      android:layout_weight="80" 
      android:text="Touch for option 3" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:textColor="#000000" /> 

     <CheckBox 
      android:id="@+id/checkBox1" 
      android:layout_weight="20" 
      android:textColor="#000000" /> 
    </TableRow> 

    <TableRow> 

     <TextView 
      android:id="@+id/textView1" 
      android:layout_weight="80" 
      android:text="Touch for option 4" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:textColor="#000000" /> 

     <CheckBox 
      android:id="@+id/checkBox1" 
      android:layout_weight="20" 
      android:textColor="#000000" /> 
    </TableRow> 

    <TableRow> 

     <TextView 
      android:id="@+id/textView1" 
      android:layout_weight="80" 
      android:text="Touch for option 5" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:textColor="#000000" /> 

     <CheckBox 
      android:id="@+id/checkBox1" 
      android:layout_weight="20" 
      android:textColor="#000000" /> 
    </TableRow> 

    <TableRow> 

     <TextView 
      android:id="@+id/textView1" 
      android:layout_weight="80" 
      android:text="Touch for option 6" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:textColor="#000000" /> 

     <CheckBox 
      android:id="@+id/checkBox1" 
      android:layout_weight="20" 
      android:textColor="#000000" /> 
    </TableRow> 

    <TableRow> 

     <TextView 
      android:id="@+id/textView1" 
      android:layout_weight="80" 
      android:text="Touch for option 7" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:textColor="#000000" /> 

     <CheckBox 
      android:id="@+id/checkBox1" 
      android:layout_weight="20" 
      android:textColor="#000000" /> 
    </TableRow> 

    <TableRow> 

     <TextView 
      android:id="@+id/textView1" 
      android:layout_weight="80" 
      android:text="Touch for option 8" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:textColor="#000000" /> 

     <CheckBox 
      android:id="@+id/checkBox1" 
      android:layout_weight="20" 
      android:textColor="#000000" /> 
    </TableRow> 

    <TableRow> 

     <TextView 
      android:id="@+id/textView1" 
      android:layout_weight="80" 
      android:text="Touch for option 9" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:textColor="#000000" /> 

     <CheckBox 
      android:id="@+id/checkBox1" 
      android:layout_weight="20" 
      android:textColor="#000000" /> 
    </TableRow> 

</TableLayout> 

답변

0

확인 다음과 같은 속성 :!

 
android:shrinkColumns 
android:stretchColumns 

또한 당신이 열 (체크 박스와 textviews로 사용하는 구성 요소에 대해 다음과 같은 속성을 확인 귀하의 사례) :

 
android:layout_column 
android:layout_span 
+0

TableLayout에서 안드로이드 : stretchColumns를 사용하고 android : layout_gravit y = CheckBox의 "right"와 이것으로 내 문제가 해결되었습니다! .... 죄송합니다. 새로운 것이므로 "유용했습니다!"라고 덧붙입니다. – 303

+0

텍스트 필드에 android : layout_gravity = "center_vertical"도 변경되었습니다. android : layout_gravity = "right"를 추가하면 텍스트 필드가 조금 움직입니다. 다시 한 번 감사드립니다! – 303

관련 문제