I am displaying JSON data inside RecyclerView , I added long press action on RecyclerView item , which display PopupWindow. I want to display that PopupWindow on Top of each Recyclerview item when i long click on it.
but PopupWindow only display on TOP of parent screen not on top of Recyclerview item.
i want that PopupWindow should display at TOP of each RecyclerView item layout.
here is my code for Displaying PopupWindow
private void PopUpWindowOption(LinearLayout mainLayout)
{
View customView = LayoutInflater.from(context).inflate(R.layout.popup,null);
Button closePopupBtn = (Button) customView.findViewById(R.id.closePopupBtn);
final PopupWindow popupWindow = new PopupWindow(customView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
closePopupBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
popupWindow.dismiss();
Toast.makeText(context,"clicked",Toast.LENGTH_SHORT).show();
}
});
popupWindow.showAtLocation(mainLayout, Gravity.TOP, 0, 0);
}
Output
How can i achieve this help me. Thank you