Android——PopupWindow
16lz
2021-12-04
实现PopupWindow透明效果,先在drawable定义一个文件:
<?xml version="1.0" encoding="UTF-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle"><gradient android:startColor="#c0000000" android:endColor="#c0000000"android:angle="90" /><!-- <stroke android:dashWidth="2dp" android:dashGap="2dp"android:width="2dp" android:color="#FF00ff00" /> 描边 --><corners android:bottomRightRadius="5dp"android:bottomLeftRadius="5dp" android:topLeftRadius="5dp"android:topRightRadius="5dp" /><!--设置圆角--></shape>
代码中:
/** * 初始化弹出等待窗口 */private void initPopWindow() {if (mPopupWindows == null) {View view = context.getLayoutInflater().inflate(R.layout.dialog_pop, null);mPopupWindows = new PopupWindow(view, 120, 100);((TextView) view.findViewById(R.id.message)).setText(mLoadingMsg);// mPopupWindows.setBackgroundDrawable(new BitmapDrawable());}if (mPopupWindows.isShowing()) {mPopupWindows.dismiss();}}
最后:
mPopupWindows.showAtLocation(context.findViewById(currentId),Gravity.CENTER, 0, 0);具体参数查看源码
更多相关文章
- android 实现button的背景改变
- Android系统中自带的图标&一些预定义样式&参考颜色值
- android 状态栏透明,源码修改教程
- Android(安卓)Q 下拉状态栏快捷开关解析
- Android编译过程详解(三)
- Android编译过程详解(三)
- Switch自定义
- Android(安卓)onMeasure自定义
- Android(安卓)Init Language(android init.rc语法)