Android 通用Dialog 框架、可定位显示

项目地址:https://github.com/xianningqis/EasyDialog

在此先感谢 https://github.com/luoshihai/XXDialog 作者

 

一个通用dialog ,有常用进出场动画,也有定位view位置显示动画(基本上常用动画都有)

拥有dialog常用效果与popupwindow 在某个view的上下左右方位显示的特性

效果

添加依赖

在project目录的build.gradle的allprojects节点添加 java maven { url "https://jitpack.io" } 如下:

    allprojects {
        repositories {
            jcenter()
            maven { url "https://jitpack.io" }
        }
    }

    dependencies {
        implementation 'com.github.xianningqis:EasyDialog:0.0.1'
    }

开始使用 

1.使用例子,详细请看demo

    new EasyDialog(this, R.layout.dialog_more_view) {//设置自己的自定义布局文件
                    @Override
                    public void onBindViewHolder(DialogViewHolder holder) {
                        //这里获取布局控件,并对其进行绑定与操作
                    }
                }.backgroundLight(0.2)
                        .setCanceledOnTouchOutside(false)
                        .setCancelAble(true)
                        .setViewBottom(view)
                        .setCustomAnimations(AnimatorHelper.TOP_IN_ANIM, AnimatorHelper.TOP_OUT_ANIM)
                        .showDialog();

 2. EasyDialog 的Api

showDialog() 显示dialog
dismiss()  销毁
setCancelAble(boolean cancel) 设置能否被取消
setCanceledOnTouchOutside(boolean cancel) 设置点击其他地方能否被取消
backgroundLight(double light) 弹出时背景亮度 值为0.0~1.0    1.0表示全黑  0.0表示全白
fromBottomToMiddle() 从底部一直弹到中间
fromBottom() 从底部弹出 显示在底部
fromLeftToMiddle() 从左边一直弹到中间退出也是到左边
fromRightToMiddle() 从右边一直弹到中间退出也是到右边
fromTop() 从顶部弹出 从顶部弹出  保持在顶部
fromTopToMiddle() 从顶部谈到中间  从顶部弹出  保持在中间
showDialog( int style) 显示一个Dialog自定义一个弹出方式  具体怎么写 可以模仿上面的
showDialog(boolean isAnimation) 如果为true 就显示默认的一个缩放动画
fullScreen() 全屏显示
fullWidth() 全屏宽度
fullHeight() 全屏高度
setWidthAndHeight(int width, int height) 自定义宽高
setOnKeyListener(DialogInterface.OnKeyListener onKeyListener) 当dialog弹出是 按键的点击事件会被dialog获取
setDialogDismissListener(OnDismissListener listener) 设置dismiss监听
setOnCancelListener(OnCancelListener listener) 设置取消监听

setViewTop(View view)在xx上方
setViewBottom(View view)在xx下方
setViewLeft(View view)在xx左方
setViewRigh(View view)在xx右方
setViewLeftBottom(View view)在xx左下方
setViewRighBottom(View view)在xx右下方
setViewLeftTop(View view)在xx左上方
setViewRighTop(View view)在xx右上方
setCustomAnimations(final int inAnimType, int outAnimType)设置自定义进场和出场动画

AnimatorHelper.java //应对自定义显示位置进出场动画,dialog样式动画无法满足该要求,因此需要自定义动画
//==========================透明度渐变==========================
    public final static int ALPHA_IN_ANIM = 100;
    public final static int ALPHA_OUT_ANIM = 101;

    public final static int TOP_ALPHA_IN_ANIM = 103;
    public final static int TOP_ALPHA_OUT_ANIM = 104;

    public final static int BOTTOM_ALPHA_IN_ANIM = 105;
    public final static int BOTTOM_ALPHA_OUT_ANIM = 106;

    public final static int LEFT_ALPHA_IN_ANIM = 107;
    public final static int LEFT_ALPHA_OUT_ANIM = 108;

    public final static int RIGHT_ALPHA_IN_ANIM = 109;
    public final static int RIGHT_ALPHA_OUT_ANIM = 110;

    //==========================缩放==========================
    public final static int ZOOM_ALPHA_IN_ANIM = 200;
    public final static int ZOOM_ALPHA_OUT_ANIM = 201;

    public final static int ZOOM_IN_ANIM = 202;
    public final static int ZOOM_OUT_ANIM = 203;

    public final static int DELAYED_ZOOM_IN_ANIM = 204;
    public final static int DELAYED_ZOOM_OUT_ANIM = 205;

    //==========================推入==========================
    public final static int TOP_IN_ANIM = 300;
    public final static int TOP_OUT_ANIM = 301;

    public final static int BOTTOM_IN_ANIM = 302;
    public final static int BOTTOM_OUT_ANIM = 303;

    public final static int LEFT_IN_ANIM = 304;
    public final static int LEFT_OUT_ANIM = 305;

    public final static int RIGHT_IN_ANIM = 306;
    public final static int RIGHT_OUT_ANIM = 307;

    //==========================圆形==========================
    public final static int CIRCULAR_REVEAL_IN_ANIM = 400;
    public final static int CIRCULAR_REVEAL_OUT_ANIM = 401;

 

 

你可能感兴趣的:(Android 通用Dialog 框架、可定位显示)