2016-06-21 5 views
0

私は、各行にいくつかのチェックボックスがあり、カスタムアダプターを使用しているテーブルレイアウトを使用しています。列は画面全体に均等に展開されます。親のレイアウトでは、一連の「チェック/チェックボックスをすべてオフにする」タイプのチェックボックスもあり、リストビューのチェックボックスと完全に並んでいます。私の問題は、チェックボックスの列見出しを列に並べることができないということです。彼らは、携帯電話とタブレットの両方のデバイスで働くことはもちろんのこと、あまりにも少なすぎるかのいずれかのクリープを持っています。私の疑念は、左端のチェックボックスに関連付けられたテキスト、それに関連付けられたテキストを持つ唯一のチェックボックスが原因で問題が発生する可能性があるということです。列見出しをカスタムリストビューのチェックボックスに合わせる

これはすべてのチェックボックスとチェックを外すための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を与えなければなりませんでした。さもなければ、最も左のチェックボックスに関連付けられたテキストの可変幅が残りの列の配置を混乱させました。テキストサイズをその列のテキストよりも大きくする必要がありました。

関連する問題