草庐IT

showAtLocation

全部标签

Android:PopupWindow.showAtLocation()

谁能告诉我函数PopupWindow.showAtLocation(View**parent**,intw,inth);中参数“parent”的详细解释提前致谢! 最佳答案 Android窗口管理器确保弹出窗口显示在显示它的Activity上方。为了让窗口管理器执行此操作,它需要知道相关Activity的窗口。由于View在窗口内,如果它知道Activity窗口内的View,它就知道Activity在哪个窗口中。使用parent参数,您说“我希望弹出窗口位于Viewparent所在窗口中的Activity上方”。

android - 调用 popupwindow 的 showAtLocation 会使应用程序崩溃

我有一个从View扩展的类,我正在尝试使用这段代码显示一个popupWindowpublicclassdbViewextendsViewimplementsView.OnTouchListener{privatevoidshowDialog(Stringmsg){LayoutInflaterlayoutInflater;ViewdialogContent;finalPopupWindowpopupWindow;layoutInflater=(LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERV

android - 重力值如何影响 Android 中的 PopupWindow.showAtLocation()

不同的重力值如何影响Android中的PopupWindow.showAtLocation()?我在PopupWindowsshowAtLocation和Gravity上找不到好的文档。 最佳答案 在尝试一些黑魔法数学计算中心并尝试使用Gravity.TOP对齐View几个小时后,我发现了一个使用Gravity.CENTER的帖子。我在这里收集我的发现,希望它可以减轻其他人的痛苦。popupWindow.showAtLocation(anyViewOnlyNeededForWindowToken,Gravity.CENTER,0,0