How to draw a dot circle inside a square drawable

2019-01-29 09:45发布

I want a small dot inside a square button , this is what i have tried till now as answered by azizbekian:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item>
        <shape android:shape="rectangle">
            <size android:width="100dp" android:height="100dp"/>
            <solid android:color="#38b0ef"/>
        </shape>
    </item>

    <item
        android:bottom="45dp"
        android:left="45dp"
        android:right="45dp"
        android:top="45dp">
        <shape android:shape="oval">
            <stroke android:width="1dp"  android:color="#0c5069"/>
            <size android:width="20dp" android:height="20dp"/>
            <solid android:color="#0c5069"/>
        </shape>
    </item>


</layer-list>

The first image is what i have tried and the second image is what i want excluding the text.

this is how it looks now this is how i want excluding the text

and also this code is the button to which i have to apply the drawable there are seven such buttons in an horizontal linearlayout with weightsum:100 each button has weight 14

<Button
   android:id="@+id/wed"
   android:layout_width="0dp"
   android:layout_height="35dp"
   android:layout_marginEnd="1dp"
   android:background="@drawable/my_button_dot"
   android:text="WED"
   android:textAllCaps="true"
   android:textStyle="bold"
   android:textColor="#ffffff"
   android:layout_weight="15"/>

the dot does not appear in the background when this drawable is applied to the button, maybe because of the size of button and drawable i tried to adjust the size of drawable, but i just do not understand it and it did not work, how can i adjust it such that the dot appears in button background.

0条回答
登录 后发表回答