【发布时间】:2026-02-10 10:00:02
【问题描述】:
我有以下 Android 布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="16dp"
android:orientation="vertical" >
<TextView
android:id="@+id/slideTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dip"
android:padding="@dimen/px20"
android:text="@string/login_message"
android:textSize="@dimen/px25"
android:textStyle="bold" />
<TextView
android:id="@+id/slideDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/password"
android:drawablePadding="@dimen/px20"
android:drawableStart="@drawable/password"
android:padding="@dimen/px20"
android:text="@string/login_message_body"
android:textSize="@dimen/px20" />
<TextView
android:id="@+id/swipeMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="" />
</RelativeLayout>
但是所有元素都位于屏幕顶部,一个在另一个之上,就像它们不占用任何空间一样。
RelativeLayout documentation 中似乎不是这样,所有元素都垂直放置在一个下方。
这是怎么回事?
【问题讨论】: