Android GridLayout边框 [英] Android GridLayout Border
本文介绍了Android GridLayout边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发Tic-Tac-Toe。
I am working on a Tic-Tac-Toe.
但是,我想为我的 GridLayout(Board)添加边框
以下是gridLayout的以下代码
Here is the following code of my gridLayout
<android.support.v7.widget.GridLayout
android:id="@+id/boardGrid"
app:columnCount="3"
app:rowCount="3"
app:alignmentMode="alignBounds"
app:layout_widthPercent="100%"
app:layout_aspectRatio="100%"
android:background="@drawable/burledwood"
android:layout_centerVertical="true">
非常感谢任何帮助。
推荐答案
创建 border.xml 文件: -
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#00fb9a"/>
<stroke
android:color="#5d05ff"
android:width="3dp"
/>
</shape>
</item>
</selector>
在GridLayout中将该背景文件应用为背景可绘制
Apply that background file as background drawable in GridLayout
<android.support.v7.widget.GridLayout
android:id="@+id/boardGrid"
app:columnCount="3"
app:rowCount="3"
app:alignmentMode="alignBounds"
app:layout_widthPercent="100%"
app:layout_aspectRatio="100%"
android:background="@drawable/border"
android:layout_centerVertical="true">
这篇关于Android GridLayout边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文