• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Checkbox custom style

bravotango

Lurker
Sep 3, 2011
4
0
Hello Android experts. As a new starter in android I am finding it almost impossible to create a custom style checkbox. Maybe this is not possible.
I am using Eclipse for Java Developers Indigo Release with Android open source plugin.
I see lots of examples showing a pretty silver checkbox but what I am getting is a smaller dark gray checkbox no matter what version of android I choose for the project. I have searched a lot and have not found anyone else experiencing this problem.
If I try to customise the checkbox to make it look like the examples the black border outline of the unwanted built-in checkbox persists and is superimposed on my custom image style.
I have to use android:background="@layout/checkboxtheme" to get this to work at all. Using style="@layout/checkboxtheme" has no effect.
I would show an image to make this clearer but am not at liberty to do this yet as I have not made enough posts.
Here is my main.xml:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android=""
androidrientation="vertical">

<CheckBox android:id="@+id/check1"
android:background="@layout/checkboxtheme"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>

<CheckBox android:id="@+id/check2"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>

<Button android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Confirm Selection"/>

<TextView android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Selected is" />

<EditText android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="EditText"
android:textSize="18sp"/>
</LinearLayout>

Here is my checkboxtheme.xml

<?xml version="1.0" encoding="utf-8"?>

<selector xmlns:android="">
<item android:state_checked="true" android:state_focused="true"
android:drawable="@drawable/btn_check_off_pressed" />
<item android:state_checked="false" android:state_focused="true"
android:drawable="@drawable/btn_check_off_selected" />
<item android:state_checked="false"
android:drawable="@drawable/btn_check_off" />
<item android:state_checked="true"
android:drawable="@drawable/btn_check_on" />
</select
 
Still same problem no matter whether the theme is in layout or drawable makes no difference.

After a bit more research found I was trying to create the project using Android 2.3 using images from version 2.2 so the dark gray checkbox is the default for version 2.3.

I now believe it is not possible to mess with custom checkbox images.
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones