我正在处理一个奇怪的问题。
我正在为 ListView
行使用以下布局:
<?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 的
可见性。但是,即使在切换可见性之后,也不会显示 vOverlay
。
为了验证代码是否按预期工作,我将 vOverlay
的高度和宽度更改为 50dp
。当我这样做时,vOverlay 的
可见性按预期工作 - 除了我需要的大小是 match_parent
。
有人可以解释我做错了什么吗?我怎样才能得到预期的结果?
最佳答案
将外部 RelativeLayout 替换为 FrameLayout 并将您的覆盖移动到该 FrameLayout 的第二个子级
关于android - 使用 match_parent 在 ListView 中覆盖 RelativeLayout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23843677/