bri*_*rig 9 android divider android-tablelayout
我想创建一个带有列分隔符的表.我想用垂直条形图像划分我的列.为了达到这个目的,我已经习惯了"android:divider="@drawable/abc" 但是没有用.下面是我的xml文件:
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:stretchColumns="*"
android:padding="5dip"
android:divider="@drawable/tracking_green"
>
<TableRow >
<TextView
android:id="@+id/retaileritem1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="xxxxxxx" />
<TextView
android:id="@+id/retaileritem2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="xxxxxxx" />
<ImageView
android:id="@+id/retailerimage1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@drawable/tracking_green" />
</TableRow>
Run Code Online (Sandbox Code Playgroud)
小智 12
添加android:showDividers ="middle"
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:stretchColumns="*"
android:padding="5dip"
android:divider="@drawable/tracking_green"
android:showDividers="middle"
>
Run Code Online (Sandbox Code Playgroud)
现在回答这个问题已经很晚了,但这是正确的方法。
对于行之间的分隔线:
<TableLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:divider="@color/colorPrimary"
android:showDividers="middle">
Run Code Online (Sandbox Code Playgroud)
对于列之间的分隔线:
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:divider="@color/colorPrimary"
android:showDividers="middle">
Run Code Online (Sandbox Code Playgroud)
说明:
中的分隔符标签<TableLayout>用于在其直接子项(即Rows )之间放置分隔符。
虽然分隔符标签<TableRow>用于在其直接子项(即列)之间放置分隔符
小智 0
由于 tablelayout 不直接提供此功能,因此一种可能的方式可能是框架布局。将所需的表格放在另一个只有一行的背景表格上方,高度/宽度为“match_parent”。添加具有所需布局权重的 3 列。将垂直分隔符图像视图添加到第二列。主表还应该在其行中使用相同的layout_weihts + margin,以使其看起来不错。
水平分隔线可以通过在“待分离”表格行之间添加图像视图来实现。
尚未测试,只是一种方法
奥奈
| 归档时间: |
|
| 查看次数: |
34925 次 |
| 最近记录: |