开源项目Meizhi学习笔记--VideoImageView
2017-02-07 11:02
134 查看
VideoImageView
黑发不知勤学早,看看又是白头翁VideoImageView用于显示视频的预览图,但是在Meizhi项目中并未触发效果。我单独把它弄成一个项目,以下是效果图。
布局代码
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_video_image_view" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="rc.loveq.customdialog.VideoImageViewActivity"> <rc.loveq.customdialog.VideoImageView android:id="@+id/video_image" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#2d1e1b" android:scaleType="centerCrop"/> /> </RelativeLayout>
VideoImageViewActivity
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_video_image_view); mVideoImage = (VideoImageView) findViewById(R.id.video_image); mVideoImage.setImageResource(R.mipmap.ic_launcher); }
VideoImageView
public class VideoImageView extends ImageView implements Animator.AnimatorListener { private boolean scale = false; public VideoImageView(Context context) { this(context, null); } public VideoImageView(Context context, AttributeSet attrs) { this(context, attrs, 0); } public VideoImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); nextAnimation(); } private void nextAnimation() { AnimatorSet anim = new AnimatorSet(); if (scale) { anim.playTogether(ObjectAnimator.ofFloat(this, "scaleX", 1.5f, 1f), ObjectAnimator.ofFloat(this, "scaleY", 1.5f, 1f)); } else { anim.playTogether(ObjectAnimator.ofFloat(this, "scaleX", 1, 1.5f), ObjectAnimator.ofFloat(this, "scaleY", 1, 1.5f)); } anim.setDuration(10987); anim.addListener(this); anim.start(); scale = !scale; } @Override public void onAnimationCancel(Animator arg0) { } @Override public void onAnimationEnd(Animator animator) { nextAnimation(); } @Override public void onAnimationRepeat(Animator arg0) { } @Override public void onAnimationStart(Animator arg0) { } }
Android属性动画完全解析(上),初识属性动画的基本用法
Android属性动画完全解析(中),ValueAnimator和ObjectAnimator的高级用法
Android属性动画完全解析(下),Interpolator和ViewPropertyAnimator的用法
相关文章推荐
- 开源项目Meizhi学习笔记--RatioImageView
- 开源项目RoundedImageView学习笔记(圆形ImageView)
- MVC学习笔记---WebViewPage(nop等开源项目的@T)
- IOS开源项目Coding学习笔记(4):SVWebViewController: 服务条款界面
- 开源项目Meizhi学习笔记--工具类的收集
- Android(java)学习笔记207:开源项目使用之gif view
- 开源项目Meizhi学习笔记
- 安卓学习笔记---RecyclerView的五大开源项目-解决办法
- 开源项目Coding学习笔记(1):EaseStartView --- 第一个界面
- IOS开源项目Coding学习笔记(2):IntroductionViewController (简介View)
- android开源项目SmartImageView设置网络图片url时抛出java.io.FileNotFoundException
- android开源项目---RoundedImageView制作圆角矩形,椭圆形以其圆形控件
- 关于开源项目android--Imagedownloader的学习笔记
- Android开源项目学习笔记_ActionBarSherlock
- 关于开源项目android--Imagedownloader的学习笔记
- GestureImageView图片浏览缩放开源项目的应用
- Android开源项目发现---ImageView 篇(持续更新)
- 关于开源项目android--Imagedownloader的学习笔记
- Android开源项目学习笔记(一)--ActionBarSherlock
- 关于开源项目android--Imagedownloader的学习笔记