java - How would I make my button who's shape is defined in my own XML file appear clickable? -


This question is already an answer here

  • 5 answers

I have a Button is the screen and how do I define how this button looks, it's using my own custom XML file.

The problem I get is that when this button is pressed Goes, usually in the pressed states, buttons appear E-giving is not affected.

My XML file

   & Lt; Solid Android: Color = "@color / PaleGoldenrod" /> & Lt; / Size & gt;  

I am not very familiar with this and Google does not produce results because my question may be unclear or I have mis-phrased it.

You need to define the state pressed while using the color state list XML resource. See.

You need to create selector resource as the background of the buttons, and then you can define a different shape XML for each state.

Very simple version:

   & Lt; Item Android: Dragon = "@ Drauble / Button_Shappy_Nurnal" /> & Lt; / Selector & gt;  

button_shape_normal.xml (this is your size drawable)

   & Lt; Solid Android: Color = "@color / PaleGoldenrod" /> & Lt; / Size & gt;  

button_shape_pressed.xml (this is your pressed state)

  & lt ;? Xml version = "1.0" encoding = "utf-8" & gt; & Lt; Size xmlns: android = "http://schemas.android.com/apk/res/android" & gt; & Lt; Corner Android: bottomLeftRadius = "7dp" Android: bottomRightRadius = "7dp" Android: Radius = "7dp" Android: topLeftRadius = "7dp" Android: topRightRadius = "7dp" /> & Lt; Solid Android: Color = "@color / pressed Coiler" /> & Lt; / Size & gt;  

You can change the size of the state of your pressed state, or whatever the point is that you can fully customize the state you suppress, but for this You have to create a new XML file.


Comments