Tuesday, June 11, 2019

How to custom button in Android using XML

Custom button have 4 items named cricle, oval, rectangle, and round.


Step 1. Cricle or round
<?xml version="1.0" encoding="UTF-8"?> - 
<shape android:shape="oval" xmlns:android="http://schemas.android.com/apk/res/android"> 
    <size android:height="100dp" android:width="100dp" /> 
    <stroke android:width="3dp" android:color="#000000" /> 
    <solid android:color="#00ff51" /> 
</shape>
Step 2.  Oval in button
<?xml version="1.0" encoding="UTF-8"?> - 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <corners android:radius="50dp" /> 
    <stroke android:color="#000000" android:width="3dp" /> 
    <solid android:color="#0004ff" /> 
</shape>
Step 3. Rectangle in button
<?xml version="1.0" encoding="UTF-8"?> - 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <stroke android:color="#000000" android:width="3dp" /> 
    <solid android:color="#ff0400" /> 
</shape>  
Step 4. Round in button
<?xml version="1.0" encoding="UTF-8"?> - 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <corners android:radius="10dp" /> 
    <stroke android:color="#000000" android:width="3dp" /> 
    <solid android:color="#fff700" /> 
</shape> 
How to custom button in Android using XML

No comments:

Post a Comment