2

I am creating a PopupWindow message on onClick event of a ImageButton, I can see the PopupWindow message on Emulator but can't see it on mobile, I have tried many mobiles from API 17 to 23.
I am not able to find the issue

@OnClick(R.id.infoRatingDetail)
public void ratingInfo(View view){
    TextView message;
    PopupWindow popup=new PopupWindow(getContext());
    View view_pop=inflater.inflate(R.layout.pop_up_detail,null);
    message=(TextView)view_pop.findViewById(R.id.pop_up_textView);
    message.setText(R.string.rating_info);
    popup.setContentView(view_pop);
    popup.setOutsideTouchable(true);
    popup.setFocusable(true);
    popup.showAsDropDown(view);
}
Pavneet_Singh
  • 36,884
  • 5
  • 53
  • 68
rookieDeveloper
  • 2,459
  • 1
  • 22
  • 44

3 Answers3

4

I don't know why but I had same problem & adding this two lines solved my problem.

popup.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
popup.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
popup.showAsDropDown(view);
popup.update();

Hope this will help you also.

buzzingsilently
  • 1,546
  • 3
  • 12
  • 18
0

Have you tried getApplicationContext() instead of getContext()?

linhtruong
  • 441
  • 3
  • 12
0

Try

popup.setWindowLayoutMode(view.LayoutParams.WRAP_CONTENT,view.LayoutParams.WRAP_CONTENT);

Omar Vodiak
  • 116
  • 3