Does anyone know how to change the button color?
but one particular button, not all the buttons of the application using the XML.
The android:backgroundTint attribute doesn't work on pre-Lollipop even with AppCompat library. Only colorButtonNormal from theme works on pre-Lollipop.
Is that true? what a shame
I'm using this drawable (is a simple green color) with a button, but when I use the button turns out to be higher than the normal button.
this is the file btn_green.xml
<?xml version="1.0" encoding="utf-8"?>
<item android:state_pressed="true"><shape>
<solid android:color="#ff5722" />
<corners android:radius="4dp" />
</shape></item>
<item android:state_focused="true"><shape android:shape="rectangle">
<solid android:color="#4caf50" />
<corners android:radius="4dip" />
<stroke android:width="1dip" android:color="#F0FC00" />
</shape></item>
<item><shape>
<solid android:color="#4caf50" />
<corners android:radius="4dp" />
</shape></item>
the button is this:
<android.support.v7.widget.AppCompatButton
android:id="@+id/btnIngresar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/btn_green"
android:text="Hello"
android:textStyle="bold" />
when i use the drawable, the button is higher than the normal button (without the drawable), i don't know why.
To change the default Button style of the application we can use the android:buttonStyle attribute in the AppTheme style inside the styles. xml.
AppCompatButton widget enhanced with emoji capability by using EmojiTextViewHelper . 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.
To add a button, that has an Android style all you need to do is to drag and drop a button from the Palette to your layout. For most versions that would mean a grey button with all corners at 2dp roundness. Check our blog, if you need to learn more about using Android Studio Layout Editor.
When I open a new android studio project, the default color for button is purple.
if you want below style
add this style your button
style="@style/Widget.AppCompat.Button.Borderless.Colored"
if you want this style
add below code
style="@style/Widget.AppCompat.Button.Colored"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With