Android PopupWindow显示在控件上方或者下方
来源:互联网 发布:知乎付费问答 编辑:程序博客网 时间:2024/05/16 14:47
项目中实现
Android PopupWindow显示在控件上方或者下方
主要代码如下
View view = mInflater.inflate(R.layout.layout_popupwindow, null);
PopUpwindowLayout popUpwindowLayout = (PopUpwindowLayout) view.findViewById(R.id.llayout_popupwindow);
popUpwindowLayout.initViews(mContext, titles, false);
final PopupWindow popupWindow = new PopupWindow(view, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
view.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
int popupWidth = view.getMeasuredWidth();
int popupHeight = view.getMeasuredHeight();
int[] location = new int[2];
// 允许点击外部消失
popupWindow.setBackgroundDrawable(new BitmapDrawable());
popupWindow.setOutsideTouchable(true);
popupWindow.setFocusable(true);
// 获得位置
v.getLocationOnScreen(location);
popupWindow.setAnimationStyle(R.style.mypopwindow_anim_style);
popupWindow.showAtLocation(v, Gravity.NO_GRAVITY, (location[0] + v.getWidth() / 2) - popupWidth / 2, location[1] - popupHeight);
附图片和Demo下载链接下载完成Demo点击打开链接
- Android PopupWindow显示在控件上方或者下方(demo)
- Android PopupWindow显示在控件上方或者下方
- Android自定义PopupWindow显示在控件上方或者下方
- Android自定义PopupWindow显示在控件上方或者下方
- Android自定义PopupWindow显示在控件上方或者下方
- PopupWindow显示在某个控件上方
- PopupWindow显示在某个控件上方
- PopupWindow显示在某个控件上方
- PopupWindow封装-view上方显示和下方显示
- popupwindow里含有listview,显示在控件上方
- 设置TabHost在手机屏幕上方、下方显示
- Android textView复制,popupwindow显示在文字上方
- Android popupwindow在指定控件正下方滑动弹出效果
- Android在指定View的下方显示PopupWindow
- android 如何让PopupWindow显示在ImageView的下方
- android popupwindow 弹出窗口在控件上方居中,比控件大一倍
- 【android】让popupwindow显示在view的上方并与该view水平居中对齐
- 【android】让popupwindow显示在view的上方并与该view水平居中对齐
- onselectstart
- DP问题各种模型的状态转移方程
- CentOS 7.0 systemctl使用说明
- c++学习之OO思想
- 深拷贝与浅拷贝
- Android PopupWindow显示在控件上方或者下方
- 抽屉效果实现原理
- python 3, 字符串连接速度
- Debian和Ubuntu的root用户
- android 守护线程Daemon解说
- 交换机端口汇聚
- 计算机网络实验之二层交换机实验
- ubuntu14.04 LTS DeskTop 安装 skyeye-1.3.3
- 黑马程序员_JavaSE基础知识总结二:结构和语句