public void showScreen(Uri uri, String path) {
// 显示当前截图
mLlSnapshot.setVisibility(View.VISIBLE);
mIvSnapshot.setImageURI(uri == null ? Uri.parse(path) : uri);
mIvSnapshot.setOnClickListener(v -> {
// 打开截图
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setDataAndType(uri == null ? Uri.fromFile(new File(path)) : uri, "image/*");
context.startActivity(intent);
});
showPicAnim(mLlSnapshot);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
mLlSnapshot.setVisibility(View.INVISIBLE);
mIvSnapshot.setImageDrawable(null);
mIvSnapshot.setOnClickListener(null);
}
}, 5000);
}
/**
* 截图动画
*/
public void showPicAnim(View view) {
ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(view, "alpha", 0.0f, 1.0f);
ObjectAnimator scaleXAnim = ObjectAnimator.ofFloat(view, "scaleX", 0.0f, 1.0f);
ObjectAnimator scaleYAnim = ObjectAnimator.ofFloat(view, "scaleY", 0.0f, 1.0f);
AnimatorSet set = new AnimatorSet();
set.playTogether(alphaAnim, scaleXAnim, scaleYAnim);
set.setDuration(500);
set.start();
}
Android开发之显示截图动画效果直到消失
猜你喜欢
转载自blog.csdn.net/xiayiye5/article/details/119110420
今日推荐
周排行