android - 如何在表格布局中设置列之间的分隔线?

标签 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>

最佳答案

添加 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"
>

关于android - 如何在表格布局中设置列之间的分隔线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10073211/

相关文章:

android - 将图像从设备拉到 pc 但无法在 pc 中的 ImageView 中查看

android - 在 ListView 中用 CheckBoxes 检查每七个框

android - 如何更改 Android 中 TabWidget 分隔线的颜色和/或可绘制对象?

java - 如何从Sql Server数据库中检索数据?

android - TableLayout 与 ConstraintLayout 性能

java - 如何解决OpenCv绘制轮廓错误

android - 没有适配器连接,跳过布局

android - 有没有办法在Android Table中卡住表格列和表格行

css - 如何在网站加载时制作 CSS 动画

html - 如何根据上面 <div> 的大小调整 <div> 的位置?