A
Button which supports compatible features on older versions of the platform, including:- Allows dynamic tint of its background via the background tint methods in
androidx.core.view.ViewCompat.
- Allows setting of the background tint using
backgroundTintandbackgroundTintMode.
- Allows setting of the font family using
fontFamily
This will automatically be used when you use
Button in your layouts and the top-level activity / dialog is provided by appcompat. You should only need to manually use this class when writing custom views.<androidx.appcompat.widget.AppCompatButton android:text="AppCompatButton" android:id="@+id/appcompatbutton" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <Button android:layout_below="@id/appcompatbutton" android:id="@+id/button" android:layout_width="wrap_content" android:text="Button" android:layout_height="wrap_content" />
- Difference between Button and AppCompactButton
To customize Button you can create xml file and set attributes from below according to your design
- change value as per requirements and remove extra attributes
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <!-- round corner --> <corners android:radius="14dp" /> <!-- multicolor shade background --> <gradient android:angle="45" android:centerX="35%" android:centerColor="#47a891" android:startColor="#e8e8e8" android:endColor="#000000" android:type="linear" /> <!-- padding inside button --> <padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp" /> <size android:width="270dp" android:height="60dp" /> <!-- Boarder color and width of border --> <stroke android:width="3dp" android:color="#878787" /> <!-- just one single color background --> <solid android:color="#878787" /> </shape>