我非常熟悉Android上的佈局,但我無法解釋這一個:奇怪布點的Android
<RelativeLayout
android:id="@+id/mask_for_not_authenticated"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:gravity="center">
<TextView
android:id="@+id/notLoggedTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="You are not logged in, you haven't any profile to be shown" />
<Button
android:id="@+id/loginButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/notLoggedTV"
android:padding="8dp"
android:layout_centerHorizontal="true"
android:text="What? How is it possible?! I want to be in!" />
</RelativeLayout>
當然,它看起來在設備上的相同和浮動按鈕沒有在佈局中。而TextView在中間。
爲什麼結果不居中?我嘗試過layout_centerInParent
,也沒有任何東西(讓gravity=center
做),沒有成功。
唯一的異常,我可以看到的是額外的** ** +'這裏的android:layout_below = 「@ + ID/notLoggedTV」'。但是,也許這個'android:layout_centerHorizontal =「true」'會干擾父母的'android:gravity =「中心'' –
這就是我在運行時不會遇到問題的原因,因爲您引用的視圖沒有創建,非常有用。 。但不是,不改變任何東西 –
'你所指的視圖不是被創建的'錯誤的:我可以看到它**已經被創建(就在按鈕之上)。如果TextView在Button下面聲明**,那麼是的,你會是對的。 –