2011-09-28 37 views
1

我想要一个复杂的ListView,在左侧有一个标题和说明,在右侧有一个复选框。我正在这样做,但是左侧的文本正在通过右侧的复选框。左边有2个TextView和右边的CheckBox的Android布局在复选框上有文本

我该如何预防?

我的布局代码目前的样子:

<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_height="fill_parent" 
android:layout_width="fill_parent" 
android:paddingTop="10dip" 
android:paddingBottom="10dip" 
android:paddingLeft="15dip"> 
<CheckBox 
    android:id="@+id/list_checkbox" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:checked="false" 
    /> 
<TextView 
    android:text="Some Title" 
    android:id="@+id/list_complex_title" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_toLeftOf="@+id/list_checkbox" 
    android:textAppearance="?android:attr/textAppearanceLarge" 
    />  
<TextView 
    android:text="Some long description Some long description Some long description Some long description Some long description." 
    android:id="@+id/list_complex_caption" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:textColor="#98AFC7" 
    android:layout_below="@+id/list_complex_title" 
    android:textAppearance="?android:attr/textAppearanceSmall" 
    /> 
</RelativeLayout> 

可惜我是新来的网站,需要更多的积分后的图像:(

如果可能的话,我想垂直居中复选框为好。

任何布局专家?

回答

0

没事做多。 。 根据您的布局代码,只需将左边距留给通过复选框的TextView即可。 它会解决你的问题。 我已经做到了。

+0

感谢您的提示! – user914453

+0

如果你设置左边距到TextView如何解决这个问题?它会保留空间左侧,但它不会解决这个问题.TextView包装在复选框右侧 – Dharmendra

+1

@Dhrmendra:如果你给TextView的左边距与复选框的宽度相同,它不会超过复选框。这个问题的问题是,文本不应该通过复选框。 –

2

写声明

android:layout_toLeftOf="@+id/list_checkbox" 

在你的描述的TextView这样,这将是无法去到复选框

+0

我已经有了,如果你仔细看:) – user914453

+0

其实,你是对的。我只对其中的一个人有过! – user914453

+0

非常感谢!有没有办法让我垂直居中该复选框? – user914453

相关问题