1

I am dealing with a weird problem.

I am using the following layout for ListView rows:

<?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>

In my list adapter, I toggle vOverlay's visibility based on a certain condition. But, even after toggling the visibility, vOverlay is not displayed.

To verify that the code works as intended, I changed the height and width of vOverlay to 50dp. When I did this, vOverlay's visibility worked as intended - except that the size I need is match_parent.

Could someone explain what I'm doing wrong? How can I get intended results?

user3264740
  • 231
  • 1
  • 2
  • 13
  • if you give size as match parent.then it will cover whole screen..just change it to wrap_content – Meenal May 24 '14 at 10:08
  • @MeenalSharma I tried `wrap_content` just now. Still, `vOverlay` is not visible. – user3264740 May 24 '14 at 10:16
  • 1
    replace outer RelativeLayout with FrameLayout and move your overlay to be a second child of that FrameLayout – pskink May 24 '14 at 10:17
  • @pskink Tried that as well while keeping the height and width as `match_parent`. Still, `vOverlay` is no show. – user3264740 May 24 '14 at 10:18
  • @Mrinali see my modified comment above – pskink May 24 '14 at 10:22
  • @pskink Wow.. just wow. Please post an answer for me to mark. It would be great if you can spare a few minutes to explain the issue with using RelativeLayout. – user3264740 May 24 '14 at 10:33
  • honestly it should work with your code, I don't know why it doesn't, Frame Layout is just a save way to get what you wanted – pskink May 24 '14 at 10:45
  • @pskink Ok. Fair enough. I'll keep this trick in mind. I will be leaving for work soon. So, it might take me some time to accept your answer (which I hope you do post). – user3264740 May 24 '14 at 10:49

1 Answers1

2

replace outer RelativeLayout with FrameLayout and move your overlay to be a second child of that FrameLayout

pskink
  • 23,874
  • 6
  • 66
  • 77