Android Popup Window 居于控件上方突出显示
2015-12-22 17:53
579 查看
public class TestPopupWindowActivity extends PopupWindow { Activity context; public TestPopupWindowActivity(Activity context, View v) { super(context); this.context = context; RelativeLayout mContentView = new RelativeLayout(context); RelativeLayout.LayoutParams lpBg = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); mContentView.setLayoutParams(lpBg); ImageView ivBg = new ImageView(context); ivBg.setImageResource(R.mipmap.icon_alipay); mContentView.addView(ivBg); mContentView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); this.setContentView(mContentView); this.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); this.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT); this.setFocusable(true); this.setBackgroundDrawable(new ColorDrawable(Color.GRAY)); this.setOutsideTouchable(true); this.update(); int popupWidth = mContentView.getMeasuredWidth(); int popupHeight = mContentView.getMeasuredHeight(); int[] location = new int[2]; v.getLocationOnScreen(location); showAtLocation(v, Gravity.NO_GRAVITY, location[0] + v.getWidth() / 2 - popupWidth / 2, location[1] - popupHeight); } }
相关文章推荐
- android中坐标系详解
- 62.在Android Studio中使用Git进行版本管理
- Android笔记(六十三) android中的动画——逐帧动画( frame-by-frame animation)
- Android提示用户更新版本
- Android-Universal-Image-Loader
- Android陀螺仪传感器学习
- Android -- Adapter
- android MotionEvent中getX()和getRawX()的区别
- 在androidstudio导入library
- android studio libs 下导入so的问题
- Android中的"Unable to start activity ComponentInfo"错误
- Android 自定义View,实现数独界面设计
- Android计步器学习-第一篇
- MPAndroidChart 教程:图表的具体设置 Specific chart settings(六)
- Android 6.0 运行时权限处理
- android蓝牙自动配对的有关问题
- android activity之间传递参数,获取上一个activity的返回结果
- Android string.xml中空格的问题
- Android版本编译,及使用fastboots烧android系统版本
- Android-Universal-Image-Loader 图片异步加载类库的使用(超详细配置)