Home java Custom Checkbox Android

Custom Checkbox Android




Good day! The following question arose:

How to make custom Chekbox in android? Here is Here There is an example of customization. Everything works, but the problem is that when creating such a custom checkbox, he disappears. Is it possible (and if so how) to customize checkbox with a daw? Can examples are there? I would like to get such a result:

Answer 1, Authority 100%

Draw two pictures – marked checkbox (checked.png) and not marked (unchecked.png) – at least with “Galka”, at least with anything.
Chekbox will look exactly as you draw it, “Galka” is not some kind of separate item, it is simply drawn with all the rest of the background together.

Do select the selector and put in res / drawable (checkbox_selector.xml):

& 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 / Checked" / & gt;
  & lt; Item Android: state_checked = "false" Android: Drawable = "@ Drawable / Unchecked" / & gt;
 & lt; / selector & gt;

You assign in the checkbox attributes on the markup. This selector:

& lt; checkbox
 Android: layout_width = "Match_Parent"
 Android: layout_height = "wrap_content"
 Android: Button = "@ Drawable / Checkbox_selector"
 Android: Text = "Checkbox" / & gt;

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions