所以我有下面的代碼,它可以很好地工作,但Android Studio抱怨使用嵌套的相對佈局是多餘的。我的問題是,做這件事的正確方法是什麼?如何正確居中相對佈局中的一組按鈕?
注意:我希望兩個/所有按鈕都作爲一個整體居中。沒有一個其他的相對於它
<?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:fitsSystemWindows="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:padding="5dp">
<Button
android:id="@+id/btnOpenRecyclerViewActivity"
style="@style/MainActivityButton"
android:text="Button 1" />
<Button
android:id="@+id/btnOpenNormalNotificationActivity"
style="@style/MainActivityButton"
android:text="Button 2"
android:layout_below="@id/btnOpenRecyclerViewActivity" />
</RelativeLayout>
</RelativeLayout>
你內在的RelativeLayout是無用的 –