2023-09-20 Android CheckBox 让文字显示在选择框的左边

一、CheckBox 让文字在选择框的左边 ,在布局文件里面添加下面一行就可以。

复制代码
android:layoutDirection="rtl" 即可实现
android:paddingStart="10dp" 设置框文间的间距

二、使用的是left to right

复制代码
        <attr name="layoutDirection">
            <!-- Left-to-Right. -->
            <enum name="ltr" value="0" />
            <!-- Right-to-Left. -->
            <enum name="rtl" value="1" />
            <!-- Inherit from parent. -->
            <enum name="inherit" value="2" />
            <!-- Locale. -->
            <enum name="locale" value="3" />
        </attr>

三、测试效果

复制代码
            <CheckBox
                android:id="@+id/new_proto_checkbox"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:layout_marginBottom="0dp"
                android:layoutDirection="rtl"
                android:paddingStart="0dp"
                android:text="new-proto"
                android:checked="false"
                android:visibility="visible"/>
相关推荐
敲代码的鱼哇42 分钟前
发送短信/拨打电话/获取联系人能力 UTS 插件(cz-sms)
android·前端·ios·uni-app·安卓·harmonyos·鸿蒙
用户5052372099151 小时前
Android 13/14 通知权限与前台服务适配指南
android
用户5052372099151 小时前
Android 12 适配指南:SplashScreen API 与 PendingIntent 变更
android
用户5052372099151 小时前
一张表看懂 Android 8-15 所有适配要点
android
_祝你今天愉快2 小时前
Android 12 (AOSP) 添加自定义系统服务
android
程序员陆业聪4 小时前
AI编码提效实战:Skill、Rule与上下文工程
android
程序员陆业聪5 小时前
AI驱动需求梳理与Spec编写:让PRD自动变成技术方案
android
李艺为6 小时前
Android Studio使用switch匹配资源id时报需要常量表达式解决办法
android
YaBingSec8 小时前
玄机靶场-2024ccb初赛sc05 WP
android·运维·网络·笔记·安全·ssh
常利兵8 小时前
解锁Android嵌入式照片选择器,让你的App体验丝滑起飞
android