【问题标题】:how to show dotted border to table layout如何在表格布局中显示虚线边框
【发布时间】:2011-03-28 16:14:33
【问题描述】:

我是android新手,想在tablelayout中显示边框。

谁能帮帮我,这对我来说非常重要。

【问题讨论】:

    标签: android tablelayout


    【解决方案1】:

    尝试将ShapeDrawable 设置为您想要添加边框的元素的背景。您可以在 res/drawables 文件夹中的 XML 文件中定义 ShapeDrawable。特别是,stroke 元素具有 dashWidthdashGaps 参数,可让您制作虚线:

    <stroke
        android:width="integer"
        android:color="color"
        android:dashWidth="integer"
        android:dashGap="integer" />
    

    你也可以只设置一个重复的点图像作为整个表格的背景,然后在单元格上设置一个纯色背景和边距(参见this trick,它是关于纯色边框的,但我相信你可以伪造带有 2x2 repeating bitmap 的棋盘图案)。

    【讨论】:

    • 我已经用按钮实现了形状...但我无法在表格布局中显示边框 1) coupon_detail_table schemas.android.com/apk/res/android" > 我不知道为什么它不起作用
    • 你不能只在布局文件中阻塞drawable的形状——你需要在drawables文件夹中自己的XML文件中定义它,然后将该drawable设置为视图的android:background你想要的布局。请参阅 ApiDemos 应用程序中的 Graphics/Drawables 演示和相关 XML 文件,了解其工作原理 (developer.android.com/resources/samples/ApiDemos/index.html)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-11
    • 2017-09-02
    • 1970-01-01
    • 2023-03-31
    相关资源
    最近更新 更多