2014-12-09 3 views
0

привет У меня проблема с флажками, которые отлично работают на Android 4.3, но не работают над версией 2.2, вот фотографии. Проблема в том, что элементы флажка обертываются и выравниваются влево в более старых версиях.выравнивание старой версии для Android

working 4.3 version

problematic 2.2 version

The Checkbox is not aligned to center in previous versions and is shifted

здесь код

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="start" 
    android:layoutgravity="start" > 

    <ImageView 
     android:id="@+id/layoutCar" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_centerInParent="true" 
     android:contentDescription="@string/car" 
     android:padding="16dp" 
     android:src="@drawable/damage_car" /> 

    <CheckBox 
     android:id="@+id/CheckBoxRightFront" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignEnd="@+id/layoutCar" 
     android:layout_alignRight="@+id/layoutCar" 
     android:layout_below="@+id/CheckBoxFront" 
     android:layout_centerInParent="true" 
     android:layout_marginTop="18dp" 
     android:button="@drawable/customcheckbox" 
     android:gravity="center" 
     android:paddingBottom="16dp" 
     android:paddingTop="16dp" /> 

    <CheckBox 
     android:id="@+id/CheckBoxLeftFront" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBaseline="@+id/CheckBoxRightFront" 
     android:layout_alignBottom="@+id/CheckBoxRightFront" 
     android:layout_alignEnd="@+id/CheckBoxLeftBD" 
     android:layout_alignLeft="@+id/layoutCar" 
     android:layout_alignRight="@+id/CheckBoxLeftBD" 
     android:layout_alignStart="@+id/layoutCar" 
     android:button="@drawable/customcheckbox" 
     android:gravity="center" 
     android:padding="16dp" /> 

    <CheckBox 
     android:id="@+id/CheckBoxBumper" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBottom="@+id/layoutCar" 
     android:layout_alignLeft="@+id/layoutCar" 
     android:layout_alignStart="@+id/layoutCar" 
     android:button="@drawable/customcheckbox" 
     android:gravity="center" /> 

    <CheckBox 
     android:id="@+id/CheckBoxBack" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBottom="@+id/layoutCar" 
     android:layout_alignLeft="@+id/CheckBoxFront" 
     android:layout_alignStart="@+id/CheckBoxFront" 
     android:button="@drawable/customcheckbox" 
     android:gravity="center" 
     android:paddingBottom="16dp" 
     android:paddingTop="16dp" /> 

    <CheckBox 
     android:id="@+id/CheckBoxRoof" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/CheckBoxBack" 
     android:layout_centerHorizontal="true" 
     android:layout_centerVertical="true" 
     android:layout_marginBottom="70dp" 
     android:button="@drawable/customcheckbox" 
     android:gravity="center_vertical|center_horizontal" /> 

    <CheckBox 
     android:id="@+id/CheckBoxFront" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_centerInParent="true" 
     android:layout_marginTop="12dp" 
     android:button="@drawable/customcheckbox" /> 

    <CheckBox 
     android:id="@+id/CheckBoxLeftFD" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBottom="@+id/CheckBoxRoof" 
     android:layout_alignLeft="@+id/layoutCar" 
     android:layout_alignStart="@+id/layoutCar" 
     android:button="@drawable/customcheckbox" 
     android:gravity="center" 
     android:paddingBottom="16dp" 
     android:paddingTop="16dp" /> 

    <CheckBox 
     android:id="@+id/CheckBoxLeftBD" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/CheckBoxBack" 
     android:layout_alignLeft="@+id/layoutCar" 
     android:layout_alignStart="@+id/layoutCar" 
     android:layout_toEndOf="@+id/CheckBoxBumper" 
     android:layout_toRightOf="@+id/CheckBoxBumper" 
     android:button="@drawable/customcheckbox" 
     android:paddingBottom="16dp" 
     android:paddingTop="16dp" /> 

    <CheckBox 
     android:id="@+id/CheckBoxRightFD" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBottom="@+id/CheckBoxRoof" 
     android:layout_alignEnd="@+id/layoutCar" 
     android:layout_alignLeft="@+id/CheckBoxRightBD" 
     android:layout_alignRight="@+id/layoutCar" 
     android:layout_alignStart="@+id/CheckBoxRightBD" 
     android:button="@drawable/customcheckbox" 
     android:padding="16dp" /> 

    <CheckBox 
     android:id="@+id/CheckBoxRightBD" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBaseline="@+id/CheckBoxLeftBD" 
     android:layout_alignBottom="@+id/CheckBoxLeftBD" 
     android:layout_alignEnd="@+id/layoutCar" 
     android:layout_alignRight="@+id/layoutCar" 
     android:button="@drawable/customcheckbox" 
     android:paddingBottom="16dp" 
     android:paddingTop="16dp" /> 

</RelativeLayout> 
+0

вы можете поделиться снимком экрана? –

+2

это проблема с заполнением темы –

+1

абсолютно не связана: но зачем поддерживать 2.2? по крайней мере, увеличить до API 10 (2.3.3) – WarrenFaith

ответ

0

Я думаю, я нашел ответ на этот вопрос в конце концов, это была другая упаковка объекта на разные версии, так что я сделал, чтобы сократить дополнительную упаковку, написав ширину, соответствующую размер изображения и переопределить Схему Оберточных систем по умолчанию

android:layout_width="[Image-width-size]dp" 

в моем случае это был

android:layout_width="20dp" 
Смежные вопросы