直播平台软件开发,自定义checkbox与文字的距离设置
直播平台软件开发,自定义checkbox与文字的距离设置
一、文字的距离设置
只需要设定CheckBox的android:paddinLeft的值即可。
二、自定义checkbox
在开发过程中经常遇到的问题是,不同厂商的checkbox控件的UI不同,导致开发出的产品在UI上有些区别,尤其是一些厂商的UI做得比较丑,这时候我们可以使用自定义Checkbox来达到我们想要的UI。
只需要在drawable文件下设定一个xml即可:
1 | <br><?xml version= "1.0" encoding= "UTF-8" ?><br><selector<br> xmlns:android= "http://schemas.android.com/apk/res/android" ><br> <item android:state_window_focused= "false" android:state_enabled= "true" android:state_checked= "true" android:drawable= "@drawable/btn_check_on" /><br> <item android:state_window_focused= "false" android:state_enabled= "true" android:state_checked= "false" android:drawable= "@drawable/btn_check_off" /><br> <item android:state_enabled= "true" android:state_checked= "true" android:state_pressed= "true" android:drawable= "@drawable/btn_check_on_pressed" /><br> <item android:state_enabled= "true" android:state_checked= "false" android:state_pressed= "true" android:drawable= "@drawable/btn_check_off_pressed" /><br> <item android:state_focused= "true" android:state_enabled= "true" android:state_checked= "true" android:drawable= "@drawable/btn_check_on_selected" /><br> <item android:state_focused= "true" android:state_enabled= "true" android:state_checked= "false" android:drawable= "@drawable/btn_check_off_selected" /><br> <item android:state_enabled= "true" android:state_checked= "false" android:drawable= "@drawable/btn_check_off" /><br> <item android:state_enabled= "true" android:state_checked= "true" android:drawable= "@drawable/btn_check_on" /><br></selector> |
在需要使用的CheckBox控件下使用android:button属性:
1 | <br><CheckBox<br> android:id= "@+id/btn_check" <br> android:button= "@drawable/checkboxselector" <br> android:layout_width= "wrap_content" <br> android:text= "测试一下" <br> android:paddingLeft= "30.0dp" <br> android:layout_height= "wrap_content" /> |
以上就是直播平台软件开发,自定义checkbox与文字的距离设置, 更多内容欢迎关注之后的文章
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现