如何在表格布局中的列之间设置分隔线? [英] How to set divider between columns in tablelayout?

查看:27
本文介绍了如何在表格布局中的列之间设置分隔线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个带有列分隔符的表格.我想用垂直条形图像分隔我的列.为了实现这一点,我使用了 "android:divider="@drawable/abc" 但它不起作用.下面是我的 xml 文件:

I want to create a table with column dividers. I want to divide my columns with a vertical bar image. To achieve this I have used "android:divider="@drawable/abc" but its not working. Below is my xml file for same:

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

Add 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"
>

这篇关于如何在表格布局中的列之间设置分隔线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆