Android GridLayout Border

后端 未结 1 808
陌清茗
陌清茗 2021-01-25 07:25

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

&         


        
相关标签:
1条回答
  • 2021-01-25 08:06

    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">
    
    0 讨论(0)
提交回复
热议问题