gpt4 book ai didi

android - android中复选框的复选标记图像的间距

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:47:22 28 4
gpt4 key购买 nike

您好,我正在尝试创建一个复选框列表,它应该如下图所示,在复选标记图像前后都有空格。

enter image description here

但是当我尝试创建复选框时,它的显示如下图所示。

enter image description here

像我展示的第一张图片一样,没有空格可以勾选图片。如果我使用填充来检查框组件,它就像 "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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com