给 Android ListView中的单元格 加入外边框怎么实现
时间: 2024-01-25 18:03:48 浏览: 88
你可以使用ListView的item布局文件实现单元格外边框的添加。具体实现步骤如下:
1. 创建一个drawable文件用于设置边框样式,比如border.xml:
```xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FFFFFF"/>
<stroke android:width="1dp" android:color="#000000"/>
</shape>
```
其中,solid标签用于设置填充颜色,stroke标签用于设置边框宽度和颜色。
2. 在ListView的item布局文件中,添加一个背景属性,引用上面创建的drawable文件:
```xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/border">
...
</RelativeLayout>
```
这样就可以为ListView的每个单元格添加外边框了。
相关问题
给 Android ListView中的每个单元格 加入外边框怎么实现
你可以使用ListView的item布局文件实现每个单元格外边框的添加。具体实现步骤如下:
1. 创建一个drawable文件用于设置边框样式,比如border.xml:
```xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FFFFFF"/>
<stroke android:width="1dp" android:color="#000000"/>
</shape>
```
其中,solid标签用于设置填充颜色,stroke标签用于设置边框宽度和颜色。
2. 在ListView的item布局文件中,添加一个背景属性,引用上面创建的drawable文件:
```xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/border">
...
</RelativeLayout>
```
这样就可以为ListView的每个单元格添加外边框了。每个单元格都会有自己的边框。
阅读全文
相关推荐
















