Android Studio - 按钮顶部的相对布局具有透明背景
Android Studio - Relative Layout on top of buttons have transparent background
我正在尝试在另一个包含 buttons
的顶部创建一个 RelativeLayout
,以便 隐藏 下面的那些。
我已经在顶部设置了黑色背景 RelativeLayout
然而,布局直到透明显示下面的对象。此外,顶部相对布局后面的 buttons
仍然可以点击。
我的问题是如何使用 RelativeLayout
来隐藏另一个包含对象的对象?顶部的相对布局应该 NOT 透明,下方的 buttons
不可 可点击。
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:visibility="gone"
android:id="@+id/buttons"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Your buttons go here -->
</RelativeLayout>
<RelativeLayout
android:id="@+id/prompt"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- your prompt -->
</RelativeLayout>
</FrameLayout>
当你完成你的提示相关布局时,然后从你的 activity 说这样的话:
View prompt = findeViewById(R.id.prompt);
prompt.setVisibility(View.GONE);
然后可见您的按钮布局
View buttonLayout = findeViewById(R.id.buttons);
buttonLayout.setVisibility(View.VISIBLE);
我正在尝试在另一个包含 buttons
的顶部创建一个 RelativeLayout
,以便 隐藏 下面的那些。
我已经在顶部设置了黑色背景 RelativeLayout
然而,布局直到透明显示下面的对象。此外,顶部相对布局后面的 buttons
仍然可以点击。
我的问题是如何使用 RelativeLayout
来隐藏另一个包含对象的对象?顶部的相对布局应该 NOT 透明,下方的 buttons
不可 可点击。
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:visibility="gone"
android:id="@+id/buttons"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Your buttons go here -->
</RelativeLayout>
<RelativeLayout
android:id="@+id/prompt"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- your prompt -->
</RelativeLayout>
</FrameLayout>
当你完成你的提示相关布局时,然后从你的 activity 说这样的话:
View prompt = findeViewById(R.id.prompt);
prompt.setVisibility(View.GONE);
然后可见您的按钮布局
View buttonLayout = findeViewById(R.id.buttons);
buttonLayout.setVisibility(View.VISIBLE);