当在android:layout_centerVertical="true"中使用Relativelayout时,它不起作用。然而,当我将它更改为android:layout="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_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:textAppearance="?android:textAppearanceLarge"
android:text="Happy" />
</RelativeLayout>我在Udacity上做了实验,并且尝试使用android:layout_centerVertical/Horizontal="true",只有水平布局起作用,我不明白为什么。我仍然是一个初学者(一个星期),所以希望得到一个解释。TY
发布于 2019-05-16 19:57:55
使用android:layout_centerVertical="true"时,移除android:layout_alignParentTop="true"并放置水平中心,移除android:layout_alignParentRight="true"。对边对齐比中心垂直/水平更优先。
https://stackoverflow.com/questions/56175380
复制相似问题