How to change android button text color globally in theme

<style name=”AppTheme.Base” parent=”Theme.AppCompat.Light.DarkActionBar”> <item name=”android:textColor”>#yourcolor</item> <item name=”android:buttonStyle”>@style/ButtonColor</item> <item name=”colorButtonNormal”>@color/buttonColor</item> </style> <style name=”ButtonColor” parent=”@android:style/Widget.Button”> <item name=”android:textColor”>@color/yourcolor</item> </style> android:textColor This should help you change the text color globally.

Make an Android button change background on click through XML

To change the image by using code: public void onClick(View v) { if(v.id == R.id.button_id) { ButtonName.setImageResource(R.drawable.ImageName); } } Or, using an XML file: <?xml version=”1.0″ encoding=”utf-8″?> <selector xmlns:android=”http://schemas.android.com/apk/res/android”> <item android:state_pressed=”true” android:drawable=”@drawable/login_selected” /> <!– pressed –> <item android:state_focused=”true” android:drawable=”@drawable/login_mouse_over” /> <!– focused –> <item android:drawable=”@drawable/login” /> <!– default –> </selector> In OnClick, just add this … Read more

How to create a circular outlined Material Button in Android?

You can use the app:shapeAppearanceOverlay attribute to define the corner size. You can use the 50% value. <com.google.android.material.button.MaterialButton android:layout_width=”50dp” android:layout_height=”50dp” style=”@style/Widget.MaterialComponents.Button.OutlinedButton.Icon” app:icon=”@drawable/ic_add_24px” app:iconSize=”24dp” app:iconGravity=”textStart” android:padding=”0dp” app:iconPadding=”0dp” android:insetLeft=”0dp” android:insetTop=”0dp” android:insetRight=”0dp” android:insetBottom=”0dp” app:shapeAppearanceOverlay=”@style/ShapeAppearanceOverlay.MyApp.Button.Circle” /> with: <style name=”ShapeAppearanceOverlay.MyApp.Button.Circle” parent=””> <item name=”cornerFamily”>rounded</item> <item name=”cornerSize”>50%</item> </style> or with the style=”@style/Widget.MaterialComponents.Button.Icon” It requires at least the version 1.1.0. With jetpack compose … Read more