我是在android上编程的新手,所以我很难理解相对布局是如何工作的。我已经得到了大部分,但android:layout_centerVertical =“true”只是当我尝试在我的代码中使用它没有工作。我应该按照从上到下的顺序排列3个textviews,所以它会显示“祝你生日快乐”,但我不能让“生日”文本视图居中。当我使用android:layout_centerInParent =“true”时,它的中心位于中间,我无法向左或向右移动它。有人能看我的代码并告诉我我做错了什么吗?谢谢。需要android的帮助:layout_centerVertical =“true”
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:textAppearance="?android:textAppearanceLarge"
android:text="Happy" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_alignParentLeft="true"
android:textAppearance="?android:textAppearanceLarge"
android:text="Birthday" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:textAppearance="?android:textAppearanceLarge"
android:text="To You" />
当您使用相对布局时,您可以为每个视图提供id,然后针对此视图安排其他视图。使用“android:layout_below”作为'生日'和'给你' –
你可以添加一张图片来描述你想要的布局吗? –