本文主要是介绍android从actionbar位置下方向滑出窗口PopupWindow,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
gif不是那么清晰
,凑合着看哈O(∩_∩)O
//以下是如何实现自定义弹出窗口,mView就是你想要展现的视图View mView = LayoutInflater.from(this).inflate(R.layout.click_booth_floating, null);WindowManager wm = this.getWindowManager();int width = wm.getDefaultDisplay().getWidth();//设置窗口的宽度mView.setMinimumWidth(width);/* 下面是对PopupWindow四个参数的详细介绍* @param contentView the popup's content* @param width the popup's width* @param height the popup's height* @param focusable true if the popup can be focused, false otherwise*/PopupWindow popupWindow = new PopupWindow(mView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT , true);//获取AppBarLayoutAppBarLayout appBar = (AppBarLayout) findViewById(R.id.map_activity_app_bar_layout);//点击popupwindow之外的地方,popupwindow消失popupWindow.setOutsideTouchable(true); //由于Android 版本差异性,在不需要背景的情况下设置背景为透明popupWindow.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.map_page_background)));//从appbar位置向下滑出PopupWindowpopupWindow.showAsDropDown(appBar);
这篇关于android从actionbar位置下方向滑出窗口PopupWindow的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!