我正在尝试在包含RelativeLayout
的另一个的顶部创建buttons
,以便隐藏以下内容。
我已将黑色背景设置为顶部RelativeLayout
但是,布局直到透明,显示下面的对象。此外,顶部相对布局后面的buttons
仍然可以点击。
我的问题是如何使用RelativeLayout
隐藏另一个包含对象的内容?顶部相对布局应该 NOT 透明,而下面的buttons
不能可点击。
答案 0 :(得分:1)
<?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>
当你完成了你的提示相对布局时,那么从你的活动中说出这样的话:
View prompt = findeViewById(R.id.prompt);
prompt.setVisibility(View.GONE);
然后可见您的按钮布局
View buttonLayout = findeViewById(R.id.buttons);
buttonLayout.setVisibility(View.VISIBLE);