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
717
votes
28 answers

How to start new activity on button click

In an Android application, how do you start a new activity (GUI) when a button in another activity is clicked, and how do you pass data between these two activities?
Adham
  • 63,550
  • 98
  • 229
  • 344
544
votes
20 answers

How to make the corners of a button round?

I want to make the corners of a button round. Is there an easy way to achieve this in Android?
artist
  • 6,271
  • 8
  • 25
  • 35
533
votes
30 answers

In Android, how do I set margins in dp programmatically?

In this, this and this thread I tried to find an answer on how to set the margins on a single view. However, I was wondering if there isn't an easier way. I'll explain why I rather wouldn't want to use this approach: I have a custom Button which…
stealthjong
  • 10,858
  • 13
  • 45
  • 84
500
votes
20 answers

Why is my Button text forced to ALL CAPS on Lollipop?

In my app "Tide Now WA" which I recently tested for compatibility using the new Nexus 9 tablet (Lollipop - API 21). It writes some button text. This app writes the text correctly using Android 2.3 and Android 4.0. I.e. mixed capital and lower case…
user1644002
  • 3,211
  • 3
  • 19
  • 21
443
votes
13 answers

How to disable an Android button?

I have created a layout that contains two buttons, Next and Previous. In between the buttons I'm generating some dynamic views. So when I first launch the application I want to disable the "Previous" button since there wont be any previous views. I…
Dijo David
  • 6,175
  • 11
  • 35
  • 46
345
votes
12 answers

Android Material Design Button Styles

I'm confused on button styles for material design. I'd like to get colorful raised buttons like in the attached link., like the "force stop" and "uninstall" buttons seen under the usage section. Are there available styles or do I need to define…
xsorifc28
  • 5,112
  • 6
  • 16
  • 24
267
votes
5 answers

Android customized button; changing text color

I made a button that changes the background drawable on different states, this way:
dwbrito
  • 5,194
  • 5
  • 32
  • 48
261
votes
28 answers

Coloring Buttons in Android with Material Design and AppCompat

Before the AppCompat update came out today I was able to change the color of buttons in Android L but not on older versions. After including the new AppCompat update I am unable to change the color for either version, when I do try the button just…
mail929
  • 2,768
  • 3
  • 15
  • 12
257
votes
10 answers

Override back button to act like home button

On pressing the back button, I'd like my application to go into the stopped state, rather than the destroyed state. In the Android docs it states: ...not all activities have the behavior that they are destroyed when BACK is pressed. When the user…
bdls
  • 4,578
  • 6
  • 24
  • 30
252
votes
11 answers

Android - border for button

How do I add a border to a button? Is it possible to do this without resorting to use of images?
jeffreyveon
  • 13,400
  • 18
  • 79
  • 129
233
votes
57 answers

Android Preventing Double Click On A Button

What is the best way to prevent double clicks on a button in Android?
Androider
  • 21,125
  • 36
  • 99
  • 158
217
votes
11 answers

Custom circle button

I want to create custom button and I need it to be circle. How can I create a circle button? I do not think that be possible with draw9patch. Also I do not know how to make custom button! Do you have any suggestion?
Ata
  • 12,126
  • 19
  • 63
  • 97
177
votes
8 answers

Android Data Binding using include tag

Update note: The above example works properly, because release 1.0-rc4 fixed the issue of needing the unnecessary variable. Original question: I do exactly as it is described in the documentation and it does not work: main.xml:
168
votes
24 answers

How to make a round button?

I'm trying to make a round button, but I don't know how can I do it. I can make button with rounded corners, but how can I can round circle. It's not the same. Please, tell me, is it possible on Android? Thank you.
user1166635
  • 2,741
  • 6
  • 22
  • 32
164
votes
14 answers

How can I remove a button or make it invisible in Android?

How can I remove a button in Android, or make it invisible?
Troj
  • 11,781
  • 12
  • 40
  • 49
1
2 3
99 100