2013-10-01 45 views
0

我有複選框的列表視圖。問題是在設備和仿真器上顯示不同的複選框。設備和模擬器上覆選框的外觀

下面是它的外觀在仿真器:

enter image description here

和它的外觀上的設備:

enter image description here

你可以看到,在設備複選框都板缺右邊緣。

這是@繪製/ 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> 

和佈局行:

<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> 

我做錯了嗎?爲什麼在模擬器上顯示正確?

+0

請再試一次,移動您所使用的繪製,華電國際文件夾中的圖像和檢查,讓我知道... – Ankit

+0

什麼也沒有發生:/ – Josef

+0

好吧,讓我檢查另一個解決方案.. – Ankit

回答

0

我想我找到了適當的解決方案。

而不是

android:button="@drawable/custom_checkbox_design" 

應該

android:button="@null" 
android:background="@drawable/custom_checkbox_design" 
1

使用XML的android UI系統相當麻煩。它根據您使用的android操作系統的版本而顯着不同。通常模擬器具有最新的android版本,而設備不具有。似乎有什麼不對您的佈局文件只是嘗試改變以下值:使用

android:layout_marginRight="40dp" 
android:button="@drawable/custom_checkbox_design" 

嘗試不同的值layout_marginRight和改變複選框的圖像。 希望這可以解決您的問題。

+0

我已經試過,沒有幫助。 Android版本是相同的。設備運行4.1.2與模擬器相同。 – Josef

+0

有趣的部分是,當我使用沒有圖形的標準複選框時工作正常。 – Josef