How to disable an Android button?
Did you try this? Update: Thanks to Gwen. Almost forgot that android:clickable can be set in your XML layout to determine whether a button can be clickable or not.
Did you try this? Update: Thanks to Gwen. Almost forgot that android:clickable can be set in your XML layout to determine whether a button can be clickable or not.
Step 1 : Create file named : my_button_bg.xml Step 2 : Place this file in res/drawables.xml Step 3 : Insert below code Step 4: Use code “android:background=”@drawable/my_button_bg” where needed eg below:
You can change the colour two ways; through XML or through coding. I would recommend XML since it’s easier to follow for beginners. XML: You can also use hex values ex. Coding:
If you want something like this here is the code. 1.Create a xml file in your drawable folder like mybutton.xml and paste the following markup: 2.Now use this drawable for the background of your view. If the view is button then something like this:
Create an xml file named roundedbutton.xml in drawable folder Finally set that as background to your Button as android:background = “@drawable/roundedbutton” If you want to make it completely rounded, alter the radius and settle for something that is ok for you.