2015-07-13 4 views
0

Я пытаюсь центрировать выравнивание флажка в строке ListView.Флажок Центра выравнивания в ListView

Каждая строка ListView содержит флажок (выравнивание по левому краю) и две строки текста (справа от флажка).

Любые идеи о том, как я устанавливаю флажок внутри строки i.e между верхним и нижним разделителями в отличие от верхней строки текста?

Мое расположение ListView приведено ниже для справки.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:orientation="horizontal" 
android:paddingTop="5dp" 
android:paddingBottom="5dp" 
> 

<CheckBox 
    android:id="@+id/cbBoxSL" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="5dp" 
    android:layout_alignParentLeft="true" 
    android:scaleX="1.4" 
    android:scaleY="1.4" 
    android:gravity="center_vertical" 

    > 
</CheckBox> 

<TextView 
    android:id="@+id/tvSLItemName" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_toRightOf="@+id/cbBoxSL" 
    android:layout_marginLeft="10dp" 
    android:layout_alignBaseline="@+id/cbBoxSL" 
    android:textSize="16sp" 
    android:textColor="@color/aqua" 
    android:singleLine="true"> 
</TextView> 

<TextView 
    android:id="@+id/tv_dateAdded" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/tvSLItemName" 
    android:layout_marginLeft="10dp" 
    android:layout_marginRight="5dp" 
    android:layout_marginTop="5dp" 
    android:textSize="12sp" 
    android:text="added on" 
    android:textStyle="italic" 
    android:textColor="@color/mid_grey" 
    android:layout_toRightOf="@id/cbBoxSL" 
    > 
</TextView> 

<TextView 
    android:id="@+id/tv_date" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/tvSLItemName" 
    android:layout_toRightOf="@+id/tv_dateAdded" 
    android:textSize="12dp" 
    android:textStyle="bold" 
    android:textColor="@color/mid_grey" 
    android:layout_alignBaseline="@+id/tv_dateAdded" 
    /> 

ответ

3

Добавить эту строку в CheckBox XML.

android:layout_centerVertical="true"

+1

работал charm..how я пропустил этот я никогда не буду знать! – ScottishUser

1

пытаются добавить android:layout_centerHorizontal="true" или/и android:layout_centerInParent="true" в макете CheckBox

Смежные вопросы