Android TableLayoutに線を引く
TableLayoutはレイアウトのxmlファイルの中で、テーブルを作れるタグです。
HTMLみたいに、border:1pxとかやって線を引けそうですが、できません。
仕方ないので、テーブルの背景に線の色を指定し、行であるTableRowの背景に城を設定し、marginを設定して隙間を空けることで、表に線をつけたように見せる方法を取ります。
以下、サンプルです。
<!--menu.xml -->
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="5dip"
android:orientation="vertical"
android:background="@color/grey05"
android:padding="1dp"
>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:background="@color/white"
android:padding="5dp"
android:layout_marginBottom="1dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/indispensable"
android:textColor="@color/red_text" >
</TextView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/company_group_id"
android:textColor="@color/black_text" >
</TextView>
</TableRow>
</TableLayout>
<!--colors.xml--> <color name="grey05">#cccccc</color> <color name="white">#FFFFFF</color>
