android sets button style (border color, fillet) and picture style (fillet)

Posted by FrozNic on Thu, 30 Apr 2020 21:02:04 +0200

android sets button style (border color, fillet) and picture style (fillet)

Set button border color:
Create a new button? Edge.xml file in drawable

<?xml version="1.0" encoding="UTF-8"?>    
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">     
<!-- Border color value --><item>     
      <shape>     
            <solid android:color="#3bbaff" />     
      </shape>     
</item>     
<!--This is the button border set to four sides and the width is 1-->
<item android:right="1dp"
android:left="1dp"
android:top="1dp"
android:bottom="1dp">
     <shape>     
<!--This is the background color-->
           <solid android:color="#ffffff" />        
<!--This is the font in the button and the margin in the button-->
           <padding android:bottom="10dp"    
                android:left="10dp"    
                android:right="10dp"    
                android:top="10dp" />    
     </shape>         
</item>    
</layer-list>

use:

   android:background="@drawable/button_edge" 

Fillet button: (in fact, the button is still square, just hiding the peripheral part)
In drawable: create a new button? Circle? Shape.xml file

<?xml version="1.0" encoding="UTF-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <!-- Color of fill -->
    <solid android:color="#FFFFFF" />
    <!-- android:radius Radius of arc -->
    <!-- Set the four corners of the button to arc -->
    <corners 
    android:radius="5dip" 
    <!--It can also be set separately-->
    android:topLeftRadius="10dp"
    android:topRightRadius="10dp"
    android:bottomRightRadius="10dp"
    android:bottomLeftRadius="10dp"
/>  
        **Set text padding**
    <!-- padding: Button The words in it Button Boundary spacing -->
    <padding
        android:left="10dp"
        android:top="10dp"
        android:right="10dp"
        android:bottom="10dp"
        />
</shape>

use:

   android:background="@drawable/shape" 

Set rounded image
Simple settings: (you can't add a custom picture, you can only set the color and font)
Create an image ﹐ circle.xml image in drawable

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#FFFFFF" />
    <corners android:topLeftRadius="10dp"
        android:topRightRadius="10dp"
        android:bottomRightRadius="10dp"
        android:bottomLeftRadius="10dp"/>
</shape>

use:

   android:background="@drawable/image_circle" 

You can fillet a custom picture

Topics: Android xml encoding