I'm facing an issue with popupWindow.showAtLocation(View parent, int gravity, int x, int y)
here x-axis is working properly but it doesn't move on y-axis. Popup window is still showing on top of activity, but it finely locating at left or right location.I'm using GridView
as a parent view, I think there is some issue with GridView but I don't know what's that issue & how to solve it.
Please somebody help me.
below is my code:
final GridView gridView = (GridView)inflater.inflate(R.layout.popup_window, null, false);
gridView.setNumColumns(5);
gridView.setVerticalSpacing(50);
PopupAdapter adapter = new PopupAdapter(this, iconIds, subjectNames);
gridView.setAdapter(adapter);
popupWindow = new PopupWindow(gridView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, false);
findViewById(R.id.open_popup_btn).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v)
{
if(!popupWindow.isShowing()) {
popupWindow.showAtLocation(gridView, Gravity.NO_GRAVITY, 100, 400);
}
else
popupWindow.dismiss();
}
});
and below is my code for popup_window.xml
<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/grid_view">
</GridView>