尝试这个。
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".Settings" >
<!-- Settings -->
<LinearLayout
android:id="@+id/settings_form"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center_horizontal"
android:orientation="vertical"
>
</LinearLayout>
<!-- Special Thanks -->
<LinearLayout
android:id="@+id/special_thanks_form"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="gone"
>
</LinearLayout>
然后在您的活动中仅引用它们
private View settingsForm;
private View specialThanksForm;
settingsForm = findViewById(R.id.settings_form);
specialThanksForm = findViewById(R.id.special_thanks_form);
然后更改按钮 clickListener 上视图的可见性
settingsForm.setVisibility(View.GONE);
specialThanksForm.setVisibility(View.VISIBLE);