【发布时间】:2014-05-24 10:01:50
【问题描述】:
我正在处理一个奇怪的问题。
我对@987654321@ 行使用以下布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:jn="http://schemas.android.com/apk/res/com.appeaser.justnoteproject"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<BUNCH OF VIEWS />
<RelativeLayout
android:id="@+id/rlCon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/margin_note_bottom"
android:layout_marginLeft="@dimen/margin_note_left"
android:layout_marginRight="@dimen/margin_note_right"
android:layout_marginTop="@dimen/margin_note_bottom" >
<BUNCH OF VIEWS />
<View
android:id="@+id/vOverlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/blue_overlay"
android:visibility="gone" />
</RelativeLayout>
</RelativeLayout>
在我的列表适配器中,我根据特定条件切换 vOverlay's 可见性。但是,即使在切换可见性之后,vOverlay 也不会显示。
为了验证代码是否按预期工作,我将vOverlay 的高度和宽度更改为50dp。当我这样做时,vOverlay's 可见性按预期工作 - 除了我需要的大小是 match_parent。
有人可以解释我做错了什么吗?我怎样才能获得预期的结果?
【问题讨论】:
-
如果你给大小匹配父级。那么它将覆盖整个屏幕..只需将其更改为 wrap_content
-
@MeenalSharma 我刚才试过
wrap_content。尽管如此,vOverlay仍然不可见。 -
用 FrameLayout 替换外部 RelativeLayout 并将您的叠加层移动到该 FrameLayout 的第二个子项
-
@pskink 也试过了,同时保持高度和宽度为
match_parent。尽管如此,vOverlay还是没有出现。 -
@Mrinali 查看我修改后的评论
标签: android xml android-layout android-relativelayout