我需要修改哪个元素以在可绘制对象及其封闭的元素之间添加填充? [英] Which element do I need to modify to add padding between a drawable and its enclosed elements?

本文介绍了我需要修改哪个元素以在可绘制对象及其封闭的元素之间添加填充?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据我学到的知识在这里,我能够在相关小部件的分组周围添加一些围栏:

Based on what I learned here, I was able to add some "fences" around groupings of related widgets:

但是,如您所见,第二个/下面的框挤满了第一个单选按钮文本。我需要修改哪个元素以添加一些空间?我是否需要在框本身中添加一些内容,该内容位于可绘制的文件夹中,并且定义如下:

But, as you can see, the second/lower box is crowding the first radio button text. Which element do I need to modify to add some space? Do I need to add something to the box itself, which lives in the drawable folder and is defined like this:

<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
    >
<stroke
    android:width="1dp"
    android:color="#f000"
    />
</shape>

...或内部的LinearLayout或相关的单选按钮(或其封闭的RadioButtonGroup小部件)?这是xml:

...or to the inner LinearLayout, or to the radio button in question (or its enclosing RadioButtonGroup widget)? Here is that xml:

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/box"
    android:orientation="vertical">

. . .

    <RadioGroup
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

        <RadioButton
            android:id="@+id/radbtnBar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/using_labels_black" />

. . .

    </RadioGroup>
</LinearLayout>


推荐答案

是的,您可以添加一些填充,这将导致增加内部空间

Yes, you can add some padding, which will result in som inner space added:

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle"
    >
    <padding
        android:left="4dp"
        android:top="4dp"
        android:right="4dp"
        android:bottom="4dp"
    />
    <stroke
        android:width="1dp"
        android:color="#f000"
    />
</shape>

可以随意尝试4dp以外的其他值(即使顶部/底部,左侧/右侧也不同) )

Feel free to experiment different values other than 4dp (even different for top/bottom, left/right sides)

这篇关于我需要修改哪个元素以在可绘制对象及其封闭的元素之间添加填充?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆