仿微信可拖动关闭的查看大图工具

####话不多说先上效果

查看大图模式

正在拖动关闭

具体版本查看github

1.引入

######1.1 在根目录gradle下添加jitpack插件

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

######1.2 在module目录gradle下添加依赖

dependencies {
        implementation 'com.github.Jungle2329:DragImageViewer:1.0.7'
}

2.使用帮助类方便使用DragImageViewer

/**
 * Created by Jungle on 2018/12/25 0025.
 *
 * @desc 查看大图使用的工具类,由于这个查看大图的库还在不断完善,可能在调用上会有大的出入,所以所有的操作都尽量
 * 放在这里,方便修改
 */

public class DragImageViewerUtils {

    /**
     * 没有共享元素启动多图查看大图
     * @param mActivity
     * @param list 图片集合
     * @param postion 起始查看图片位置,从0开始
     * @param <T> DragImage子类
     */
    public static <T extends DragImage> void startWithoutElement(Activity mActivity, List<T> list, int postion) {
        DragImageViewer.startWithoutElement(mActivity, list, postion);
    }

    /**
     * 有共享元素启动多图查看大图
     * @param mActivity
     * @param list 图片集合
     * @param postion 起始查看图片位置,从0开始
     * @param view 要共享动画的view
     * @param <T> DragImage子类
     */
    public static <T extends DragImage> void startWithElement(Activity mActivity, List<T> list, int postion, View view) {
        DragImageViewer.startWithElement(mActivity, list, postion, view);
    }

    public static <T extends DragImage> void startWithoutElement(Activity mActivity, T t, int postion) {
        DragImageViewer.startWithoutElement(mActivity, t, postion);
    }

    public static <T extends DragImage> void startWithElement(Activity mActivity, T t, int postion, View view) {
        DragImageViewer.startWithElement(mActivity, t, postion, view);
    }


    /**
     * 接管Activity的setExitSharedElementCallback
     * 针对多图viewpager会把该图片移动走的情况,
     * 待完善,先不用调用
     *
     * @param activity
     */
    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    private static void setSharedElementCallback(Activity activity, View view) {
        ActivityCompat.setExitSharedElementCallback(activity, new android.support.v4.app.SharedElementCallback() {
            @Override
            public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
                super.onMapSharedElements(names, sharedElements);
                sharedElements.put("share_view", view);
            }
        });
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值