gpt4 book ai didi

android - 如何实现圆角表格?

转载 作者:太空宇宙 更新时间:2023-11-03 12:38:44 24 4
gpt4 key购买 nike

这就是我想要的:

enter image description here

这是我所做的:

enter image description here

不同之处在于线条和边框之间有一些空格,因为我使用了 padding=10dp 作为外边框:

<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF"/>
<stroke android:width="2dp" android:color="#808080"/>
<corners
android:radius="10dp"/>
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp"/>
</shape>

我这样做对吗?我该如何解决这个问题?

最佳答案

这里是你想要的xml文件。

从您的 xml 文件中删除 Padding,并将 padding 放入每个小部件中。这里的 test.xml 是没有填充属性的背景 xml 文件。

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center_horizontal"
android:background="@drawable/test"
android:layout_margin="10dp">

<TextView
android:id="@+id/textView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Sample TextView"
android:padding="10dp"/>

<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#000000" />

<TextView
android:id="@+id/textView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Sample TextView"
android:padding="10dp"/>

</LinearLayout>

编辑 test.xml文件

<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF"/>
<stroke android:width="2dp" android:color="#808080"/>
<corners
android:radius="10dp"/>

</shape>

enter image description here

关于android - 如何实现圆角表格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12401871/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com