作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
您好,我正在尝试创建一个复选框列表,它应该如下图所示,在复选标记图像前后都有空格。
但是当我尝试创建复选框时,它的显示如下图所示。
像我展示的第一张图片一样,没有空格可以勾选图片。如果我使用填充来检查框组件,它就像 "android:padding=50dp" 它在检查标记图像和文本之间留出空间。但不要在开始时留出空间。即在复选标记图像之前。下面是我的复选框的 xml 布局
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="15dp">
<CheckBox android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:button="@drawable/btn_check_square"
android:background="@drawable/filter_item_background"
android:textColor="@android:color/black"
android:padding="5dp"
android:text="check box text"/>
</LinearLayout>
感谢任何解决此问题的帮助。
最佳答案
这是用下面的代码解决的。
<CheckBox
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/filter_item_background"
android:button="@android:color/transparent" //Make button null
android:drawableLeft="@drawable/btn_check_square" //Create button in drawable
android:drawablePadding="20dp" //Set space between Text & CB
android:padding="5dp"
android:text="check box text"
android:textColor="@android:color/black" />
关于android - android中复选框的复选标记图像的间距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14597966/
我是一名优秀的程序员,十分优秀!