我正在 ImageButton
的 onClick
事件上创建 PopupWindow
消息,我可以看到 PopupWindow
消息在模拟器上可以看到,但在手机上看不到,我已经尝试了很多手机,从 API 17 到 23。
我找不到问题
@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);
}
最佳答案
我不知道为什么,但我遇到了同样的问题,添加这两行解决了我的问题。
popup.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
popup.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
popup.showAsDropDown(view);
popup.update();
希望这对您也有帮助。
关于android - 无法在移动设备上显示 PopupWindow 消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39362897/