Android-如何在复选框中反转文本的位置

问题描述 投票:0回答:2

是否有任何属性可以在不创建单独的文本视图的情况下更改复选框视图中的文本位置?

它一定是这样的

文字------->复选框

android android-layout android-widget
2个回答
1
投票

这是如何做

    <CheckBox 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:button="@null"
            android:drawableRight="@drawable/checkbox_selector"
            android:text="The Label goes here"
        />

诀窍是你必须定义一个drawable选择器,指定所有4个状态的位图,然后使用该选择器作为drawableRight。

这样您就可以在标签的所有4个边上指定复选框(左上角和下边)


0
投票

像这样对我有用,layoutDirection:

<CheckBox
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="I'm left of the box!!!"
    android:layoutDirection="rtl"/>
© www.soinside.com 2019 - 2024. All rights reserved.