2016-06-21 7 views
0

각 행에 여러 확인란이 있고 사용자 지정 어댑터를 사용하는 테이블 레이아웃을 사용하고 있습니다. 열은 화면에서 균등하게 확장됩니다. 부모 레이아웃에는 일련의 "check/uncheck all"유형 체크 박스가 있으며 listview 체크 박스와 완벽하게 일치합니다. 내 문제는 그 열에 정렬 할 확인란의 열 제목을 얻을 수 없다는 것입니다. 휴대 전화 및 태블릿 기기 모두에서 작동하는 것은 물론 지나치지 않거나 너무 적음에도 크리프가 있습니다. 내 의문은이 문제는 가장 왼쪽의 확인란과 관련된 텍스트, 텍스트와 연결된 텍스트 만있는 문제 때문에 발생할 수 있습니다.사용자 지정 목록보기 확인란에 열 머리글 맞추기

모든 체크 박스와 체크 박스의 체크 표시/체크 해제를위한 xml입니다.

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <TableLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@color/light_blue" 
     android:orientation="horizontal"> 

     <TableRow 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <CheckBox 
       android:id="@+id/checkBox1" 
       android:layout_height="match_parent" 
       android:layout_weight="1" 
       android:width="60dp" 
       android:background="@color/light_blue" 
       android:focusable="false" 
       android:focusableInTouchMode="false" 
       android:text="Ck all" 
       android:textSize="15dp" 
       android:textStyle="bold" /> 
      <CheckBox 
       android:id="@+id/checkBoxI" 
       android:layout_height="match_parent" 
       android:layout_weight="1" 
       android:background="@color/light_blue" 
       android:focusable="false" 
       android:focusableInTouchMode="false" /> 

      <CheckBox 
       android:id="@+id/checkBoxII" 
       android:layout_height="match_parent" 
       android:layout_weight="1" 
       android:background="@color/light_blue" 
       android:focusable="false" 
       android:focusableInTouchMode="false" /> 

이 열 머리글을위한과 일치하지 않습니다. 등

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <TableLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@color/light_blue" 
     android:orientation="horizontal"> 

     <TableRow 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <TextView 
       android:layout_height="match_parent" 
       android:layout_weight="1" 
       android:width="60dp" 
       android:gravity="center" 
       android:background="@color/light_blue"/> 
      <TextView 
       android:layout_height="match_parent" 
       android:layout_weight="1" 
       android:background="@color/light_blue" 
       android:gravity="center" 
       android:text="I"/> 
      <TextView 
       android:layout_height="match_parent" 
       android:gravity="center" 
       android:layout_weight="1" 
       android:background="@color/light_blue" 
       android:text="I"/> 

도 일치하지 않는 다른 시도이다.

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <TableLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@color/light_blue" 
     android:orientation="horizontal"> 

     <TableRow 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <TextView 
       android:layout_height="match_parent" 
       android:width="60dp" 
       android:layout_weight="1" 
       android:text="" 
       android:gravity="center" 
       android:background="@color/light_blue" 
       android:focusable="false" 
       android:focusableInTouchMode="false"/> 
      <TextView 
       android:id="@+id/keycode" 
       android:layout_height="match_parent" 
       android:gravity="center" 
       android:layout_weight="1" 
       android:background="@color/light_blue" 
       android:text="I" 
       android:textStyle="bold" /> 

      <TextView 
       android:layout_height="match_parent" 
       android:gravity="center" 
       android:layout_weight="1" 
       android:background="@color/light_blue" 
       android:focusable="false" 
       android:focusableInTouchMode="false" 
       android:text="II" 
       android:textStyle="bold" /> 

나는 텍스트 정렬의 다양한 조합을 시도하고, 심지어는 물론 기기에서 작동하지 않을 열 너비를 강제로 시도했습니다 등. 나는 하루 종일이 일을 보냈으며 여전히 단서가 없습니다. 어떤 도움을 주셔서 감사합니다.

답변

0

좋아, 그건 내 어리 석다. 커팅하고 붙여 넣을 때 테이블 행 주위에 LinearLayouts를 남겼다는 사실을 잊어 버렸습니다. Linearlayouts를 제거한 후에는 예상대로 줄 지어있었습니다. 첫 번째 열에는 textsize parm을 주어야했지만, 그렇지 않으면 가장 왼쪽의 확인란과 관련된 텍스트의 가변 너비가 나머지 열의 정렬을 엉망으로 만들었습니다. 텍스트 크기를 해당 열의 텍스트보다 크게 만들어야했습니다.