0

I want to show popup window with Recycler view for menu.

popup window top right corner -> i am showing sort up arrow icon.

So i set the transparent background for popup window and showing recycler view with white background.

`menu.setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));`


<androidx.recyclerview.widget.RecyclerView
    android:id="@+id/rvCategory"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="vertical"
    android:elevation="10dp"
    android:background="@drawable/popup_bg"/>

elevation is not working for recycler view. Its not looking like menu without border and elevation. popup

Kindly help me to solve this issue.

1 Answer 1

0

To get your desired look you can modify your popup view xml like this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <androidx.cardview.widget.CardView xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/cardView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_marginStart="10dp"
        android:layout_marginEnd="20dp"
        android:layout_marginBottom="10dp"
        app:cardCornerRadius="6dp"
        app:cardElevation="6dp">

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/rvCategory"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:paddingStart="10dp"
            android:paddingTop="5dp"
            android:paddingEnd="1dp"
            android:paddingBottom="5dp"
            android:clipToPadding="false"
            android:scrollbars="vertical" />
    </androidx.cardview.widget.CardView>
</LinearLayout>

and in the code where you initialize your popup it should be like this(here mContext is your Activity):

PopupWindow mPopup = new PopupWindow(mContext);
View popUpView = mContext.getLayoutInflater().inflate(R.layout.your_popup_xml, null);
// other initializations
mPopup.setBackgroundDrawable(null);
mPopup.setContentView(popUpView);
mPopup.setFocusable(true);
mPopup.setClippingEnabled(true);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.