Android GridLayout Border

android, java

Solution

Create A border.xml file:-

<?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>

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">

Problem

I am working on a Tic-Tac-Toe. However, i want to add a border to my `GridLayout(Board)` 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"> ``` Any help is greatly appreciated.

Original source