/*This will looke like your border without the textview
(you can make the textview color blue from your adapter or your layout file) */
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="@color/grid_view_color"/>
<stroke android:width="1dp" android:color="#001414"/>
</shape>
2)网格项目形状已按下
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#ffc392"/>
<stroke android:width="2dp" android:color="#001414"/> //choose your own color here
</shape>
3条答案
按热度按时间falq053o1#
您可以使用GridView执行此操作
将
android:numColumns
设置为所需的数字。并将选择器作为背景添加到GridView中js4nwp542#
这看起来像是
GridView
对于这种类型的边框,您需要一种形状:
您需要在drawable文件夹中创建2个形状和一个选择器:
1)正常状态(未按下)
2)为您的紧迫状态
3)将用作gridItem背景的最终形状
1)网格项目形状
2)网格项目形状已按下
3)网格_项目_背景
kyvafyod3#
如果块(框)的大小可变,则可以选择GridView
其他
选择嵌套在LinearLayout中的一些视图(TextView或Button)
对于选择颜色,您可以添加一个选择器到drawable文件夹,请参考Selector Example