所以我有下面的代码,它可以很好地工作,但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是无用的 –