Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android layout Android对齐元素+;相对于父元素的边距_Android Layout - Fatal编程技术网

Android layout Android对齐元素+;相对于父元素的边距

Android layout Android对齐元素+;相对于父元素的边距,android-layout,Android Layout,使用I-can-use将一个元素与另一个元素对齐 android:layou alignLeft等 但如何添加边距或填充: <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="5dp" > <TextView android:layout_wi

使用I-can-use将一个元素与另一个元素对齐

android:layou alignLeft

但如何添加边距或填充:

<RelativeLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content" 
    android:layout_marginBottom="5dp" >
    <TextView 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:layout_alignParentLeft="true"
        android:text="@string/students"
        android:textSize="30sp"
        android:typeface="normal"
        android:layout_marginTop="10dp"
        android:paddingTop="5dp"
        android:paddingBottom="5dp"
        android:id="@+id/student" />    

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@id/student"
        android:paddingLeft="20dp"
        android:paddingTop="30dp"
        android:text="@string/stud_describe"
        android:textSize="10sp"
        android:textStyle="italic"
        android:typeface="sans" />
</RelativeLayout>


在第二个
TextView
中填充顶部没有任何效果。

看起来填充和边距混淆了。将第二个
文本视图更改为:

layout_marginTop="30dp" 
而不是

paddingTop="30dp".

填充填充
视图本身,使其更大。边距更改
文本视图在其容器中的位置(
RelativeLayout
),并且不改变其大小。

看起来您将填充和边距弄混了。将第二个
文本视图更改为:

layout_marginTop="30dp" 
而不是

paddingTop="30dp".

填充填充
视图本身,使其更大。边距更改
TextView
在其容器中的位置(
RelativeLayout
),并且不改变其大小。

是的,添加填充将在TextView顶部和文本内部部分之间提供b=填充。然而,边距将在textview的顶部和上方项目的底部之间留出空间。一个简单的方法是给你的文本视图一个背景色。是的,添加填充将在文本视图的顶部和文本的内部区域之间提供b=填充。然而,边距将在textview的顶部和上方项目的底部之间留出空间。一个简单的方法是给你的文本视图一个背景色,这样你就可以看到你在做什么。