ListView边框颜色

发布于 2024-12-05 21:44:21 字数 578 浏览 4 评论 0原文

是否可以在 ListView 周围创建 1px 宽度的彩色边框?

我尝试了以下编码:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient android:startColor="#BFFFFFFF" android:endColor="#BFFFFFFF" />
    <corners android:bottomRightRadius="10dp" android:radius="10dp"
        android:bottomLeftRadius="10dp" android:topLeftRadius="10dp"
        android:topRightRadius="10dp" />
</shape>

那么...有谁知道我如何制作边框线并设置其颜色?

PS:我确实在另一篇文章中搜索过这个问题,但没有成功,这就是我创建这个问题的原因。

谢谢!

Is it possible to create a 1px width, colored border around a ListView?

I tried the following coding:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient android:startColor="#BFFFFFFF" android:endColor="#BFFFFFFF" />
    <corners android:bottomRightRadius="10dp" android:radius="10dp"
        android:bottomLeftRadius="10dp" android:topLeftRadius="10dp"
        android:topRightRadius="10dp" />
</shape>

So... does anyone know how I can make a border line and set its color?

PS: I really searched for this issue in another posts and no success, that's why I created this one.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

东走西顾 2024-12-12 21:44:21

是的,这是可能的。只需添加 标签,如下所示。

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient android:startColor="#BFFFFFFF" android:endColor="#BFFFFFFF" />
    <stroke
        android:width="1dp"
        android:color="#d8d8d8" />
    <corners android:bottomRightRadius="10dp" android:radius="10dp"
        android:bottomLeftRadius="10dp" android:topLeftRadius="10dp"
        android:topRightRadius="10dp" />
</shape>

请使用 1dp 而不是 1px,您可以根据需要替换任何边框颜色。

Yes, it is possible. Just add the <stroke> tag as shown below

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient android:startColor="#BFFFFFFF" android:endColor="#BFFFFFFF" />
    <stroke
        android:width="1dp"
        android:color="#d8d8d8" />
    <corners android:bottomRightRadius="10dp" android:radius="10dp"
        android:bottomLeftRadius="10dp" android:topLeftRadius="10dp"
        android:topRightRadius="10dp" />
</shape>

Please use 1dp instead of 1px and you can replace any border color as you wish for.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文