zoukankan      html  css  js  c++  java
  • PopupWindow 从底部弹出窗体

    第一步  : 初始化PopupWindow

        private void initPop() {
    
            if (view == null) {
                // 照片
                view = View.inflate(RegisterActivity.this, R.layout.pop_phone, null);   / /加载对象
            }
            if (mPopupWindow == null) {
                mPopupWindow = new PopupWindow(view, LayoutParams.MATCH_PARENT,
                        LayoutParams.WRAP_CONTENT, true);
            }
    
        }

    第二步 ,点击事件打开开

        // 打开pop
        private void openPopup() {
            mPopupWindow.setBackgroundDrawable(new ColorDrawable(Color
                    .parseColor("#b0000000")));  //设置背景颜色
            mPopupWindow.showAtLocation(register_lay_out, Gravity.BOTTOM, 0, 0);
            mPopupWindow.setAnimationStyle(R.style.app_pop);
            mPopupWindow.setOutsideTouchable(true);   //点击外面关闭
            mPopupWindow.setFocusable(true);    //得到焦点
            mPopupWindow.update();
          }
    R.style.app_pop
        <style name="AppTheme" parent="android:Theme.Light" />
            <style name="app_pop">
            <item name="android:windowEnterAnimation">@anim/pop_up</item>
            <item name="android:windowExitAnimation">@anim/pop_down</item>
        </style>
    pop_up.xml
    <?xml version="1.0" encoding="utf-8"?>
    <translate xmlns:android="http://schemas.android.com/apk/res/android"
        android:fromXDelta="0"
        android:toXDelta="0"
        android:fromYDelta="100%"
        android:toYDelta="0%"
        android:duration="200">
    </translate>
    pop_down.xml
    <?xml version="1.0" encoding="utf-8"?>
    <translate xmlns:android="http://schemas.android.com/apk/res/android"
        android:fromXDelta="0"
        android:toXDelta="0"
        android:fromYDelta="0%"
        android:toYDelta="100%"
        android:duration="200">
    </translate>

    附录 :打开前 先判断 关闭

        private void dismissPopupWindow() {
            // 把旧的弹出窗体关闭掉。
            if (mPopupWindow != null && mPopupWindow.isShowing()) {
                mPopupWindow.dismiss();
                // mPopupWindow = null;
            }
        }
  • 相关阅读:
    centos7 安装redis服务及phpredis扩展
    centos7 LANMP 安装
    php reids 单机命令
    浅谈正向代理和反向代理
    php-fpm日志告警"seem busy"
    PHP-redis中文文档
    Nginx配置文件nginx.conf中文详解
    生成带参数的微信二维码
    微信临时二维码时为32位非0整型
    [Linux]Service mysql start出错(mysql: unrecognized service)解决方法
  • 原文地址:https://www.cnblogs.com/java-g/p/4221858.html
Copyright © 2011-2022 走看看