background disappears on PopupWindow with ListView.

JF.0444JF.0444 USMember ✭✭✭
edited October 18 in Xamarin.Android

Hi i've run into a strange issue. I have a PopupWindow with a single ListView. The PopupWindow is just a linear layout with one ListView. The background of the linear layout is a light gray and the background of the ListView is white. If the ListView contains too many items it becomes scrollable and when the pop up is shown the background of both the ListView and LinenarLayout are transparent. If I scroll to the bottom of the list view the correct background colors reset. I have tried adding android:cacheColorHint="@android:color/transparent" and android:scrollingCache="false" with no luck. If I simply increase the height so the ListView doesn't need to scroll everything works, but there may be many items or a just few.

xml for popup window:

< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minWidth="25px"
android:minHeight="25px"
android:background="#ffbdbdbd">
< ListView
android:minWidth="25px"
android:minHeight="25px"
android:scrollingCache="false"
android:cacheColorHint="@android:color/transparent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/ListView"
android:layout_margin="5dp"
android:background="#ffffffff" />
< /LinearLayout >

code showing popup:

private void ActionButtonClicked(object sender, EventArgs args)
    {
        var button = sender as Button;

        var view = LayoutInflater.From(Activity).Inflate(Resource.Layout.PopupWindowItem, null, false);

    //PopupMenuItem is subclass of PopupWindow
        var popup = new PopupMenuItem(view, 250, 200, true);

        popup.ShowAsDropDown(button);
    }
Sign In or Register to comment.