仿Boss直聘-查看头像

简介: 发现Boss直聘app做的还是,比较不错的吧。。先看效果,致谢 Image-ZoomerGIF.gif怎么用?@Overridepublic void onClick(View v) {super.

发现Boss直聘app做的还是,比较不错的吧。。先看效果,致谢 Image-Zoomer

GIF.gif

怎么用?

<pre>

@Override
public void onClick(View v) {
super.onClick(v);
if (R.id.tv == v.getId()) {
startActivity(ZoomActivity.class);
} else if (R.id.iv == v.getId()) {
new BossZoomHelper(this, imageView, 400);
}
}
</pre>

原理很简单,

<pre>
package org.alex.bosszoomanim;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.graphics.Rect;
import android.support.v7.widget.ContentFrameLayout;
import android.view.View;
import android.view.animation.DecelerateInterpolator;
import android.widget.FrameLayout;
import android.widget.ImageView;

import org.alex.util.LogUtil;

/**
* 作者:Alex
* 时间:2016/10/8 12:48
* 简述:
*/
public class BossZoomHelper {
private Animator animator;
private ImageView copyImageView;

public BossZoomHelper(final Activity activity, final View originalView) {
    this(activity, originalView, 400);
}

public BossZoomHelper(final Activity activity, final View originalView, final long duration) {
    if (animator != null) {
        animator.cancel();
    }
    final ContentFrameLayout container = (ContentFrameLayout) activity.findViewById(android.R.id.content);
    copyImageView = new ImageView(activity);
    int matchParent = FrameLayout.LayoutParams.MATCH_PARENT;
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(matchParent, matchParent);
    copyImageView.setLayoutParams(params);
    if (originalView instanceof ImageView) {
        copyImageView.setImageDrawable(((ImageView) originalView).getDrawable());
    } else {
        Bitmap bm = view2Bitmap(originalView);
        if (bm != null) {
            copyImageView.setImageBitmap(bm);
        }
    }
    copyImageView.setVisibility(View.GONE);
    container.addView(copyImageView);
    final Rect startRect = new Rect();
    final Rect endRect = new Rect();
    Point offsetPoint = new Point();
    originalView.getGlobalVisibleRect(startRect);
    /\*\*
     \* r 是 绝对(global)坐标参数,包含状态栏、ActionBar、底部虚拟键
     \* globalOffset 用于将global坐标转换成local坐标,这里的local坐标,是相对于内容区的坐标,也就是除了状态栏和action bar和虚拟按键的区域。
     \* \*/
    container.getGlobalVisibleRect(endRect, offsetPoint);
    startRect.offset(-offsetPoint.x, -offsetPoint.y);
    endRect.offset(-offsetPoint.x, -offsetPoint.y);
    final float startScale;
    float scaleSize;
    float startScaleFinal;
    LogUtil.e("-offsetPoint.x = " + (-offsetPoint.x) + " -offsetPoint.y = " + (-offsetPoint.y));
    LogUtil.e("startRect.width()  = " + startRect.width() + " startRect.height() = " + startRect.height());
    LogUtil.e("endRect.width()  = " + endRect.width() + " endRect.height() = " + endRect.height());

    if ((float) endRect.width() / (float) endRect.height() > (float) startRect.width() / (float) startRect.height()) {
        startScale = (float) startRect.height() / (float) endRect.height();
        scaleSize = startScale \* (float) endRect.width();
        startScaleFinal = (scaleSize - (float) startRect.width()) / 2.0F;
        startRect.left = (int) ((float) startRect.left - startScaleFinal);
        startRect.right = (int) ((float) startRect.right + startScaleFinal);
    } else {
        startScale = (float) startRect.width() / (float) endRect.width();
        scaleSize = startScale \* (float) endRect.height();
        startScaleFinal = (scaleSize - (float) startRect.height()) / 2.0F;
        startRect.top = (int) ((float) startRect.top - startScaleFinal);
        startRect.bottom = (int) ((float) startRect.bottom + startScaleFinal);
    }
    copyImageView.setPivotX(0.0F);
    copyImageView.setPivotY(0.0F);

    AnimatorSet showAnimatorSet = new AnimatorSet();
    showAnimatorSet.setDuration(duration);
    showAnimatorSet.play(ObjectAnimator.ofFloat(copyImageView, View.X, new float[]{(float) startRect.left, (float) endRect.left}))
            .with(ObjectAnimator.ofFloat(copyImageView, View.Y, new float[]{(float) startRect.top, (float) endRect.top}))
            .with(ObjectAnimator.ofFloat(copyImageView, View.SCALE_X, new float[]{startScale, 1.0F}))
            .with(ObjectAnimator.ofFloat(copyImageView, View.SCALE_Y, new float[]{startScale, 1.0F}));
    showAnimatorSet.setInterpolator(new DecelerateInterpolator());
    showAnimatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            copyImageView.setVisibility(View.VISIBLE);

        }

        public void onAnimationEnd(Animator animation) {
            animator = null;
        }

        public void onAnimationCancel(Animator animation) {
            destroy(originalView, container);
        }
    });
    showAnimatorSet.start();

    animator = showAnimatorSet;
    copyImageView.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            if (animator != null) {
                animator.cancel();
            }
            copyImageView.setBackgroundColor(0);
            AnimatorSet hiddenAnimatorSet = new AnimatorSet();
            hiddenAnimatorSet.play(ObjectAnimator.ofFloat(copyImageView, View.X, new float[]{(float) startRect.left}))
                    .with(ObjectAnimator.ofFloat(copyImageView, View.Y, new float[]{(float) startRect.top}))
                    .with(ObjectAnimator.ofFloat(copyImageView, View.SCALE_X, new float[]{startScale}))
                    .with(ObjectAnimator.ofFloat(copyImageView, View.SCALE_Y, new float[]{startScale}));
            hiddenAnimatorSet.setInterpolator(new DecelerateInterpolator());
            hiddenAnimatorSet.setDuration(duration);
            hiddenAnimatorSet.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationStart(Animator animation) {
                    super.onAnimationStart(animation);
                }

                public void onAnimationEnd(Animator animation) {
                    if (animator != null) {
                        animator.cancel();
                    }
                    destroy(originalView, container);
                }

                public void onAnimationCancel(Animator animation) {
                    destroy(originalView, container);
                }
            });
            hiddenAnimatorSet.start();
            animator = hiddenAnimatorSet;
        }
    });
}

private void destroy(View originalView, ContentFrameLayout container) {
    originalView.setAlpha(1.0F);
    copyImageView.setVisibility(View.GONE);
    container.removeView(copyImageView);
    animator = null;
}

private Bitmap view2Bitmap(View view) {
    view.setDrawingCacheEnabled(true);
    view.buildDrawingCache();
    Bitmap bmp = view.getDrawingCache();
    if (bmp == null) {
        return null;
    }
    Bitmap bp;
    bp = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight());
    view.destroyDrawingCache();
    return bp;
}

}

</pre>

https://github.com/Alex-Cin/BossAnim

目录
相关文章
|
缓存 安全 Nacos
nacos常见问题之Nacos报错权限认证失败如何解决
Nacos是阿里云开源的服务发现和配置管理平台,用于构建动态微服务应用架构;本汇总针对Nacos在实际应用中用户常遇到的问题进行了归纳和解答,旨在帮助开发者和运维人员高效解决使用Nacos时的各类疑难杂症。
|
9月前
|
运维 分布式计算 自动驾驶
别再手写运维脚本了:Operator 才是数据平台的“自动驾驶系统”
别再手写运维脚本了:Operator 才是数据平台的“自动驾驶系统”
715 3
|
12月前
|
人工智能 监控 Cloud Native
云原生AI赋能文旅数智化转型:玄晶引擎AI数字员工落地长白山康养项目全解析
本文以长白山大健康企业为例,介绍其通过玄晶引擎云原生AI数字员工实现“养生+文旅”模式智能化升级的实践。涵盖技术架构、运营适配、营销创新与落地经验,展现AI在内容生产、客服转化、B端获客等环节的全链路赋能,助力企业收益率提升47%、团队扩张35%,为文旅产业数智化转型提供可复用范本。
739 13
|
12月前
|
SQL 关系型数据库 Shell
Postgresql入门之psql用法详解(四)- 高级功能
psql 是 PostgreSQL 的交互式命令行工具,支持模式匹配、变量替换、SQL 插值、自定义提示符及行编辑功能。通过 `\d` 等元命令可按名称模式查看对象,支持通配符与正则表达式。变量可动态设置并安全插值到 SQL 中,提升脚本灵活性。提供丰富的环境变量与配置文件(如 `.psqlrc`)来自定义行为,兼容不同终端与编码环境,适用于本地或远程数据库管理。
|
8月前
|
存储 人工智能 监控
Coze 智能体开发标准流程
在Coze平台开发AI智能体分四步:创建(手动或AI生成)、编排(人设/插件/工作流/知识库)、调试(多轮测试+节点监控)、发布(多渠道+API)。国内版用豆包模型,国际版支持GPT-4o/Claude。结构化Prompt与工作流是提效关键。(239字)
|
存储 人工智能 数据可视化
从零构建能自我优化的AI Agent:Reflection和Reflexion机制对比详解与实现
AI能否从错误中学习?Reflection与Reflexion Agent通过生成-反思-改进循环,实现自我优化。前者侧重内容精炼,后者结合外部研究提升准确性,二者分别适用于创意优化与知识密集型任务。
2419 9
从零构建能自我优化的AI Agent:Reflection和Reflexion机制对比详解与实现
|
12月前
|
云安全 弹性计算 安全
阿里云安全体检实测体验报告:守护云上资产的第一道防线
阿里云安全体检实测体验报告:守护云上资产的第一道防线
496 2
|
存储 人工智能 API
SPO:如何优化提示词?大模型最懂如何优化自己!开源自监督提示词优化工具,让AI自主优化提示词
本文介绍由DeepWisdom与香港科技大学联合研发的SPO框架,通过自我监督机制实现大语言模型提示优化,仅需3个样本即可达到SOTA效果,优化成本降低至传统方法的1.1%-5.6%。
3341 0
SPO:如何优化提示词?大模型最懂如何优化自己!开源自监督提示词优化工具,让AI自主优化提示词
|
机器学习/深度学习 人工智能 安全
60_隐私保护模型:联邦学习变体
在当今数字化时代,数据隐私保护已成为人工智能发展中不可忽视的核心议题。随着大型语言模型(LLM)规模的不断扩大,其对训练数据的需求也呈指数级增长,这使得数据隐私与模型性能之间的矛盾日益凸显。2025年,联邦学习作为一种创新的分布式学习范式,正在重塑LLM的训练和部署方式,允许多方在保护数据隐私的前提下共同构建高性能模型。
565 0
|
移动开发 安全 JavaScript
SpringBoot接入微信JSSDK,看这篇妥妥的
这篇教程详细介绍了如何在Spring Boot项目中接入微信JSSDK,实现H5页面的自定义分享和调用相册选取图片等功能。文章首先通过对比理想与现实的分享效果,引出了接入微信JSSDK的必要性。接着,作者提供了GitHub和Gitee上的项目源码链接,并逐步讲解了整个接入过程的关键步骤,包括配置文件、主要类和方法的实现细节,以及必要的微信公众号设置。此外,还特别强调了几个常见问题及其解决方案,如域名绑定、IP白名单设置和签名验证等。最后,通过实际测试验证了功能的正确性。适合初学者快速上手微信JSSDK接入。
677 8
SpringBoot接入微信JSSDK,看这篇妥妥的