Home > Back-end >  What is the difference between Button and Androidx.appcompat.widget.AppCompatButton in Android Devel
What is the difference between Button and Androidx.appcompat.widget.AppCompatButton in Android Devel

Time:09-24

I am trying to create a Sign Up page in the latest Android Studio Arctic. So I am trying to customize and style the buttons using Button Class, but no observable changes were made, until I used AppCompatButton, and all the styles and customization for the button were implemented. I want an elaboration between the two Views and why I could not make the changes using Button Class. Thanks.

These are the codes for AppCompatButton and Button

<androidx.appcompat.widget.AppCompatButton
                android:id="@ id/sign_up_text"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="5dp"
                android:background="@drawable/button_border_signin"
                android:elevation="0dp"
                android:text="Sign Up"
                android:textColor="#e0e0e0e0"
                android:textStyle="bold" />

Button

<Button
                android:id="@ id/sign_up_text"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="5dp"
                android:background="@drawable/button_border_signin"
                android:elevation="0dp"
                android:text="Sign Up"
                android:textColor="#e0e0e0e0"
                android:textStyle="bold" />

CodePudding user response:

Possible Reason

You might be using some features that are not compatible for older versions in your background drawable file.


Difference between Button and AppCompatButton

An AppCompatButton is simply a Button which supports compatible features on older versions of the platform, including:

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.

Source: AppCompatButton

  • Related