Questions tagged [android-button]

questions about the android.widget.Button element. This element can be used on activities.

On Android, buttons can be generated programmatically in Java code or by using xml layouts. Usually a listener(OnClickListener) is set on the Button to receive an event when the user touches the Button. The listener can be set in code or by using the android:onClick attribute in the xml layout, setting it to point to a method written in the Activity class.

Initial help

2399 questions
70
votes
15 answers

How to custom switch button?

I am looking to Custom The Switch Button to becoming as following : How to achieve this ?
TooCool
  • 10,598
  • 15
  • 60
  • 85
69
votes
9 answers

Rounded corners on material button

I'm following the tips from questions like this to create a button style like suggested on Material Design. However, I need to change the corner radius and haven't been able to do so by inheriting Widget.AppCompat.Button.Colored style and setting…
69
votes
4 answers

How to add buttons at top of map fragment API v2 layout

I am trying to show maps in android using API v2. I want UI some thing like this.But whenever I try to add button in layout it does not reflect in output I am able to get maps without buttons.I need buttons to integrate with map like below code for…
sandeep_jagtap
  • 1,484
  • 2
  • 17
  • 24
56
votes
6 answers

Disabled color state of Material button

The Material Spec shows a disabled button state that looks greyed out. https://www.material.io/design/components/buttons.html#toggle-button I am using the MaterialButton from the material components from…
lostintranslation
  • 23,756
  • 50
  • 159
  • 262
48
votes
6 answers

implement android:src="@drawable/image" programmatically in Android

I am trying to set the foreground image on an image button. After some research, I came across this code sample:
user788511
  • 1,726
  • 2
  • 30
  • 52
47
votes
6 answers

Android Background Drawable Not Working in Button Since Android Studio 4.1

I find out that since Android Studio 4.1 I cannot change the background color of a Button by setting color on its android:background, just no effect. And custom Drawable is not working as well. My background Drawable:
43
votes
2 answers

android - How can I make a button flash?

Is there any way, in code, to make a button flash continually and then stop flashing when pressed?
ron
  • 5,219
  • 8
  • 39
  • 44
42
votes
7 answers

How do I set the disabled color of a button with AppCompat?

I use this style to change the background color of my Button: