【问题标题】:Android : Button and left border in Radio ButtonAndroid:单选按钮中的按钮和左边框
【发布时间】:2019-02-01 15:10:10
【问题描述】:

有没有办法在无线电圆和左边框之间留出空间。我试图提供边距但它不起作用,我也尝试提供填充但它增加了文本和按钮之间的空间。

电台xml代码:

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <RadioGroup
            android:id="@+id/radioGroup1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <RadioButton
                android:id="@+id/chkIos"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginStart="@dimen/_12sdp"
                android:layout_marginLeft="@dimen/_12sdp"
                android:layout_marginEnd="@dimen/_5sdp"
                android:layout_marginRight="@dimen/_5sdp"
                android:layout_weight="1"
                android:background="@drawable/option_layout"
                android:button="@drawable/custom_checkbox"
                android:gravity="center"
                android:padding="@dimen/_12sdp"
                android:text="1211asd3"
                android:textColor="@color/black" />


            <RadioButton
                android:id="@+id/radio1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/option_layout"
                android:button="@drawable/custom_checkbox"
                android:layout_marginStart="@dimen/_42sdp"
                android:padding="@dimen/_12sdp"
                android:text="RadioButton2"
                android:layout_marginLeft="@dimen/_42sdp" />


            <!--<TextView-->
            <!--android:layout_weight="1"-->
            <!--android:layout_width="match_parent"-->
            <!--android:layout_height="wrap_content" />-->
        </RadioGroup>
    </LinearLayout>

有谁知道怎么做?

【问题讨论】:

  • 您好@NileshRathod 在您的回答中,他没有为按钮提供任何可绘制按钮,这就是为什么按钮和左边距之间有空间......谢谢,但这并不能解决问题
  • 您需要在源图像中手动为您的图标添加内边距,默认图标有一些内边距。

标签: android android-radiobutton android-radiogroup


【解决方案1】:

不要将图像直接粘贴到可绘制文件夹中,而是尝试从

导入它们
File -> new -> Image Asset

它将显示以下对话框,您需要在其中选择 图标类型 作为 操作栏和选项卡图标,并使用填充控件添加填充。默认图标中有一些填充,如果您需要更多空间,请尝试添加至少 5% 的填充并更改值

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-09
    • 2011-12-03
    • 2017-08-20
    • 1970-01-01
    • 1970-01-01
    • 2023-04-09
    • 1970-01-01
    • 2012-04-20
    相关资源
    最近更新 更多