自定义views 读书点点Android

Android 下拉拖拽关闭Activity,下拉返回Activ

2022-04-18  本文已影响0人  大鼓书

Github链接,给个Star鼓励我写更多好库

下拉拖拽关闭Activity,下拉返回Activity。
仿大众点评、快手、小红书详情界面:可下滑关闭详情界面。

功能(优点):

作者说明:

效果gif图(Gif图有点卡,实际运行一点都不卡):


导入

    allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }

    dependencies {
            implementation 'com.github.QDong415:QDragClose:v1.0.1'
    }

使用

        QDragRelativeLayout contentLayout = findViewById(R.id.drag_layout);
        contentLayout.setOnDragCloseListener(this);
        //传入列表的点击项目的ImageView的坐标
        contentLayout.setupFromImageView(fromX, fromY, fromWidth, fromHeight, transition_share_view);
    <declare-styleable name="QDragClose">
        <!-- 是否可以手势下拉,默认true -->
        <attr name="dragEnable" format="boolean" />
        <!-- 下拉距离占总height百分之多少就触发关闭,0 - 1之间,默认0.2 -->
        <attr name="closeYRatio" format="float" />
        <!-- 手指快速下滑也可以触发关闭,默认true -->
        <attr name="flingCloseEnable" format="boolean" />
        <!-- 手势下拉过程中,其他View根据滑动距离半透明,默认false -->
        <attr name="alphaWhenDragging" format="boolean" />
        <!-- 关闭动画耗时,默认450 -->
        <attr name="closeAnimationDuration" format="integer" />
        <!-- 下拉力度不够,反弹回正常状态动画耗时,默认200 -->
        <attr name="rollToNormalAnimationDuration" format="integer" />
    </declare-styleable>

Author:DQ

Github链接,给个Star鼓励我写更多好库

上一篇 下一篇

猜你喜欢

热点阅读