Android实现底部半透明弹出框PopUpWindow效果
Android底部半透明弹出框PopUpWindow,供大家参考,具体内容如下
成都创新互联专注为客户提供全方位的互联网综合服务,包含不限于成都做网站、网站建设、监利网络推广、成都微信小程序、监利网络营销、监利企业策划、监利品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;成都创新互联为所有大学生创业者提供监利建站搭建服务,24小时服务热线:028-86922220,官方网址:www.cdcxhl.com
layout布局:
<?xml version="1.0" encoding="utf-8"?>
布局示意:

代码部分:
/*
* 在当前页面调用initPopUpWindow方法,底部弹出popUpWindow
* 重点在popUpWindow的layout最外层布局设置android:background="#66fafafa" 半透明
* */
private void initPopUpWindow(View root, final String uuid, final String title){
Log.d("click","init popopop");
//inflate得到布局 ,底部弹出框的View
final View popView = LayoutInflater.from(mContext).inflate(
R.layout.layout_bottom_popwindow, null);
View rootView = root; // 当前页面的根布局
//创建popUpWindow对象 宽高占满页面
final PopupWindow popupWindow = new PopupWindow(popView,
WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
popupWindow.setTouchable(true);
// 设置弹出动画
popupWindow.setAnimationStyle(R.style.anim_edit_text_popup);
// 显示在根布局的底部
popupWindow.showAtLocation(rootView, Gravity.BOTTOM | Gravity.LEFT, 0,
0);
//点击底部弹出框之外的部分让popUpWindow 消失
popView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int height = popView.findViewById(R.id.ll_popupwindow).getTop();
int y=(int) event.getY();
if(event.getAction()==MotionEvent.ACTION_UP){
if(y
} }); }
动画部分
进入时从最下方弹出到最上方
消失时从最上方向下移动直到隐藏
popup_in:
<?xml version="1.0" encoding="utf-8"?>
pop_out:
<?xml version="1.0" encoding="utf-8"?>
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持创新互联。
本文名称:Android实现底部半透明弹出框PopUpWindow效果
网站URL:http://www.jxjierui.cn/article/pcsiog.html


咨询
建站咨询
