Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/224.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 如何使用间距将一个视图与另一个视图的右侧对齐?_Android - Fatal编程技术网

Android 如何使用间距将一个视图与另一个视图的右侧对齐?

Android 如何使用间距将一个视图与另一个视图的右侧对齐?,android,Android,我想将我的视图与另一个视图的右侧对齐,但它们之间有一定的间距。我想用规则的右边来做这个。我搜索了很多,但找不到合适的解决方案。第二个视图可以使用margin\u left属性或paddingLeft属性,如下所示: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match

我想将我的
视图
与另一个
视图
的右侧对齐,但它们之间有一定的间距。我想用规则的右边来做这个。我搜索了很多,但找不到合适的解决方案。

第二个视图可以使用margin\u left属性或paddingLeft属性,如下所示:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>

<TextView
    android:id="@+id/View1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello" />

<TextView
    android:id="@+id/View2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@+id/View1"
    android:layout_marginLeft="10dp"
    android:text="World" />


</RelativeLayout>

第二个视图可以使用margin\u left属性或paddingLeft属性,如下所示:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>

<TextView
    android:id="@+id/View1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello" />

<TextView
    android:id="@+id/View2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@+id/View1"
    android:layout_marginLeft="10dp"
    android:text="World" />


</RelativeLayout>

使用android:toRightOf=“@+id/other_视图”使用android:toRightOf=“@+id/other_视图”