android - Custom checkbox image - but can still see original? -


I was using the standard Android checkbox, but when I installed my app on other people's phones for testing, So the checkbox was different on each phone.

On a single phone, the checkbox was so light that when the box was checked, you hardly could see the box.

So I tried to create a custom checkbox checked image.

It worked well, but can I still see the original multi-checkbox image in the background?

Any ideas why?

Here's my checkable linear layout, honestly I'm not even sure that I need it?

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; com.myapp.myappname.CheckableLinearLayout xmlns: Android = "http://schemas.android.com/apk/res/android" Android: layout_width = "match_parent" Android: layout_height = "match_parent" Android: orientation = "horizontal" & Gt; & Lt; Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: text = "checkbox" Android: background = "@drawable / custom checkbox" /> & Lt; TextView Android: id = "@ + id / textView1" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: text = "TextView" /> & Lt; ImageView Android: id = "@ + id / imageView1" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" /> & Lt; /com.myapp.myappname.CheckableLinearLayout>   

Then I have a custom list queue that is my custom list view:

  & lt ;? xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; com.myapp.myappname.CheckableLinearLayout xmlns: Android = "http://schemas.android.com/apk/res/android" Android: layout_width = "match_parent" Android: layout_height = "match_parent" Android: orientation = "horizontal" & Gt; & Lt; RelativeLayout xmlns: Android = "http://schemas.android.com/apk/res/android" Android: layout_width = "fill_parent" Android: layout_height = "wrap_content" Android: orientation = "horizontal" Android: padding = "5dp "& Gt; & Lt ;! - Thumbnail image - & gt; & Lt; LinearLayout Android: Android: Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: padding = "3pp" Android: layout_lagaprint = "true" Android: layout_margin right = "5dp" & gt; & Lt; ImageView Android: id = "@ + id / list_image" Android: layout_width = "60dip" Android: layout_height = "60dip" Android: focusable = "false" /> & Lt; / LinearLayout & gt; & Lt ;! - File name - & gt; Android: Android: Android: Android: Layout_height = "wrap_ content" Android: layout_blo = "@ id / title" Android: text collar = "# 343434" Android: text size = "12 DP" Android: layout_margintop = "10dp "Android: Layout_toariteoff =" @ + ID / Thumbnail "Android: Focus =" Wrong "Android: Text =" Some Text. " / & Gt; Android: Focus = "False" Android: layout_alignParentRight = "true" Android: background = "@draubable / Android: Android: Android: Layout_hett =" wrap-content "custom checkbox" Android: enabled = "wrong" /> & Lt; / RelativeLayout & gt; & Lt; /com.myapp.myappname.CheckableLinearLayout>  
  & lt; Selector xmlns: android = "http: / /  - & gt; & Lt; Item Android: state_checked = "true" android: drawable = "@drawable / check" /> & Lt ;! - & lt; Item Android: Dragon = "@ Drable / Uncheck" /> & Amp; Lt; & Amp; Ndash; Default & amp; Ndash; & Amp; Gt; - & gt; & Lt; / Selector & gt;    

The attribute you want to change is the button , Not background .

First of all, design your custom graphics for different button states. Use a state listing drauble () to add different images, for example:

  & 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_checked = "true" android: drawable = "@drawable / check" /> & Lt; Item Android: state_checked = "false" android: drawable = "@drawable / uncheck" /> & Lt; / Selector & gt;   

Save it to your Drawable Resource folder, like my_checkbox.xml. Now, use the Button feature on your checkbox layout definition:

    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -