Button with background image and corner radious in android -


I am trying to create a button with a back ground image. Then I want to implement some state style with selector xml. I have used this XML as a style below and as the second selector. But background image is not showing

  & lt; Style name = "Home menu button" parent = "@ Android: style / widget button" & gt; & Lt; Item name = "Android: gravity" & gt; Centrally | Center_heagonital & lt; / Item & gt; & Lt; Item name = "android: textColor" & gt; #ffffff & lt; / Item & gt; & Lt; Item name = "Android: Shadow color" & gt; # FF000000 & lt; / Item & gt; & Lt; Item name = "android: shadowDx" & gt; 0 & lt; / Item & gt; & Lt; Item name = "android: shadowDy" & gt; -1 & lt; / Item & gt; & Lt; Item name = "android: shadowRadius" & gt; 5 & ​​lt; / Item & gt; & Lt; Item name = "Android: text size" & gt; 16dip & lt; / Item & gt; & Lt; Item name = "Android: Text Style" & gt; Bold & lt; / Item & gt; & Lt; Item name = "Android: Background" & gt; @drawable / button_back & lt; / Item & gt; & Lt; Item name = "Android: Focusable" & gt; True & lt; / Item & gt; & Lt; Item name = "Android: clickable" & gt; True & lt; / Item & gt; & Lt; / Style & gt; & Lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Selector xmlns: Android = "http://schemas.android.com/apk/res/android" & gt; & Lt; Items & gt; & Lt; Size xmlns: android = "http://schemas.android.com/apk/res/android" & gt; & Lt; Stroke Android: width = "2dp" Android: color = "@ color / red" /> & Lt; Solid Android: Color = "#FFFFFFF" /> & Lt; Padding android: left = "5dp" android: top = "2dp" Android: right = "5dp" Android: bottom = "2dp" /> & Lt; Corners Android: Radius = "15dp" /> & Lt; / Size & gt; & Lt; / Item & gt; & Lt; Item Android: state_pressed = "true" & gt; & Lt; Size xmlns: android = "http://schemas.android.com/apk/res/android" & gt; & Lt; Stroke Android: width = "2dp" Android: color = "@ color / red" /> & Lt; Solid Android: Color = "@color / blue" /> & Lt; Padding android: left = "5dp" android: top = "2dp" Android: right = "5dp" Android: bottom = "2dp" /> & Lt; Corners Android: Radius = "15dp" /> & Lt; / Size & gt; & Lt; / Item & gt; & Lt; / Selector & gt;    

I have tried your code now and it shows the background you want.

Have you added Android: Style layout is the attribute in xml? Something like this:

  & lt; Button Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" android: text = "Hello World!" Style = "@ style / homeman button" />   

In addition to this, your state of origin is not painted. You may have to change it a bit by moving the suppressed state items before the normal position.

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Selector xmlns: Android = "http://schemas.android.com/apk/res/android" & gt; & Lt; Item Android: state_pressed = "true" & gt; & Lt; Size xmlns: android = "http://schemas.android.com/apk/res/android" & gt; & Lt; Stroke Android: width = "2dp" Android: color = "@ color / red" /> & Lt; Solid Android: Color = "@color / blue" /> & Lt; Padding android: left = "5dp" android: top = "2dp" Android: right = "5dp" Android: bottom = "2dp" /> & Lt; Corners Android: Radius = "15dp" /> & Lt; / Size & gt; & Lt; / Item & gt; & Lt; Items & gt; & Lt; Size xmlns: android = "http://schemas.android.com/apk/res/android" & gt; & Lt; Stroke Android: width = "2dp" Android: color = "@ color / red" /> & Lt; Solid Android: Color = "#FFFFFFF" /> & Lt; Padding android: left = "5dp" android: top = "2dp" Android: right = "5dp" android: bottom = "2dp" /> & Lt; Corners Android: Radius = "15dp" /> & Lt; / Size & gt; & Lt; / Item & gt; & Lt; / Selector & gt;    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -