I think i found proper solution.
Instead of
android:button="@drawable/custom_checkbox_design"
should be
android:button="@null"
android:background="@drawable/custom_checkbox_design"
Question
I have list view with checkboxes. Problem is in different showing checkboxes on device and on emulator.
Here is how it looks in emulator:
and how it looks on device:
You can see that on device checkbox have cutted right edge.
This is @drawable/custom_checkbox_design.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="@drawable/checked" />
<item android:state_checked="false" android:drawable="@drawable/unchecked" />
</selector>
and layout for rows:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<CheckBox
android:id="@+id/ColChk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="40dp"
android:button="@drawable/custom_checkbox_design"
android:layout_gravity="center_vertical|center_horizontal" />
<TextView
android:id="@+id/ColOpis"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minLines="1"
android:scrollHorizontally="false"
android:text="Opis"
android:textSize="20sp" />
<TextView
android:id="@+id/ColCode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Code"
android:visibility="invisible" />
</LinearLayout>
What I'm doing wrong? Why on emulator is showed correctly?
La solution 2
I think i found proper solution.
Instead of
android:button="@drawable/custom_checkbox_design"
should be
android:button="@null"
android:background="@drawable/custom_checkbox_design"
Autres conseils
The android UI system using XML is quite buggy. It differs significantly based on the version of android operating system you use. Usually emulator has latest android version while devices do not. There seems to be nothing wrong with your layout file just try changing the following values:
android:layout_marginRight="40dp"
android:button="@drawable/custom_checkbox_design"
Try using different values for layout_marginRight and changing images of checkbox. Hope this solves your problem.