【问题标题】:how to give border for tablerow in tablelayout in android?如何在android的tablelayout中为tablerow提供边框?
【发布时间】:2011-04-06 06:08:04
【问题描述】:

我需要在TableLayout 中显示TableRow 周围的边框。

我该怎么做???

【问题讨论】:

    标签: android android-layout android-tablelayout


    【解决方案1】:

    我给出一个想法 -> 使用 shape 标签创建一个 xml 文件

    像这样

    <?xml version="1.0" encoding="UTF-8"?>
      <shape xmlns:android="http://schemas.android.com/apk/res/android">
      <solid android:color="#FFFFFF"/>
      <stroke android:width="2dp" android:color="#515151"/>
      <corners android:radius="3dp" />
      <padding android:left="10dp" android:top="5dp"
        android:right="10dp" android:bottom="5dp" />
    </shape>
    

    在您的表格布局的 android:background="@drawable/xmlFilename" 中设置此 xml 文件

    它为您的表格布局提供边框

    【讨论】:

    • 因为我无法通过 xml 文件添加背景,但能够通过 .java 文件 tablelayout.setBackgroundResource(R.layout.shape) 添加此功能;
    • android:background="R.layout.xmlFilename" 是错误的做法。请改用android:background="@drawable/filename_of_xml"
    猜你喜欢
    • 2012-05-17
    • 2014-10-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-26
    相关资源
    最近更新 更多