开源项目地址:https://github.com/castorflex/FlipImageView

  本实例我没做什么改动,就是添加了注释,方便大家阅读。和之前一样,导入library和工程文件即可明白如何使用。

布局文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
android:gravity="center_horizontal"> <fr.castorflex.android.flipimageview.library.FlipImageView
android:id="@+id/imageview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="center"
android:layout_gravity="center"
android:src="@drawable/ic_action_star_0"
app:flipDrawable="@drawable/ic_action_star_10"
app:flipDuration="5000"
app:flipInterpolator="@android:anim/bounce_interpolator"
app:flipRotations="y|x|z"
app:reverseRotation="true"/> <TextView
android:id="@+id/textview"
android:layout_marginTop="24dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" /> <Spinner
android:id="@+id/spinner"
android:layout_height="wrap_content"
android:layout_width="match_parent" /> <SeekBar
android:id="@+id/seekbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_marginTop="16dp"
android:max="5000"
android:progress="500" /> <LinearLayout
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="match_parent"> <TextView
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:text="duration:" /> <TextView
android:id="@+id/textview_duration"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="500" />
</LinearLayout> <LinearLayout
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_marginTop="16dp"
android:minHeight="48dp"
android:gravity="center"> <CheckBox
android:id="@+id/checkedtextview_x"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Rot. X" /> <CheckBox
android:id="@+id/checkedtextview_y"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Rot. Y"
android:checked="true"/> <CheckBox
android:id="@+id/checkedtextview_z"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Rot. Z" /> </LinearLayout> <CheckBox
android:id="@+id/checkedtextview_reverse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Reverse rotation" /> </LinearLayout>

SampleActivity

package fr.castorflex.android.flipimageview.sample;

import android.app.Activity;
import android.os.Bundle;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.AnticipateOvershootInterpolator;
import android.view.animation.BounceInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.view.animation.OvershootInterpolator;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.SeekBar;
import android.widget.Spinner;
import android.widget.TextView; import fr.castorflex.android.flipimageview.R;
import fr.castorflex.android.flipimageview.library.FlipImageView; public class SampleActivity extends Activity implements FlipImageView.OnFlipListener,
SeekBar.OnSeekBarChangeListener { /**
* 定义翻转的模式,用作spinner的数据
*/
private static final String[] fData = new String[]{
"Decelerate",
"Accelerate",
"AccelerateDecelerate",
"Bounce",
"Overshoot",
"AnticipateOvershoot" }; private static final Interpolator[] fInterpolators = new Interpolator[]{
new DecelerateInterpolator(),
new AccelerateInterpolator(),
new AccelerateDecelerateInterpolator(),
new BounceInterpolator(),
new OvershootInterpolator(),
new AnticipateOvershootInterpolator()
}; private SeekBar mSeekBar; private Spinner mSpinner; private TextView mTextViewDuration; private FlipImageView mFlipImageView; private CheckBox mCheckBoxX; private CheckBox mCheckBoxY; private CheckBox mCheckBoxZ; private CheckBox mCheckBoxReverse; private TextView mTextViewAnimationListener; /**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main); //翻转成功、翻转中的表示文字,用监听器触发
mTextViewAnimationListener = (TextView) findViewById(R.id.textview);
//将要翻转的图片
mFlipImageView = (FlipImageView) findViewById(R.id.imageview);
//设置翻转模式的spinner
mSpinner = (Spinner) findViewById(R.id.spinner);
//提示选择翻转时间的文字
mTextViewDuration = (TextView) findViewById(R.id.textview_duration);
//设置翻转时间的滑动条
mSeekBar = (SeekBar) findViewById(R.id.seekbar);
//选择翻转轴的选择框,X Y Z轴,不进行轴旋转,可以多选
mCheckBoxX = (CheckBox) findViewById(R.id.checkedtextview_x);
mCheckBoxY = (CheckBox) findViewById(R.id.checkedtextview_y);
mCheckBoxZ = (CheckBox) findViewById(R.id.checkedtextview_z);
//没设置XYZ轴翻转的情况下,此选项进行简单的缩放翻转
mCheckBoxReverse = (CheckBox) findViewById(R.id.checkedtextview_reverse); mSpinner.setAdapter(
new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, fData)); mSeekBar.setOnSeekBarChangeListener(this); mFlipImageView.setOnFlipListener(this);
} /////////////////////FLIP IMAGE VIEW/////////////////// @Override
public void onClick(FlipImageView view) {
//设置效果 mFlipImageView.setInterpolator(interpolator)
mFlipImageView.setInterpolator(fInterpolators[mSpinner.getSelectedItemPosition()]);
//设置时间,时间是毫秒
mFlipImageView.setDuration(mSeekBar.getProgress());
//设置翻转的轴、或不按轴翻转,传入的参数都是boolean型
mFlipImageView.setRotationXEnabled(mCheckBoxX.isChecked());
mFlipImageView.setRotationYEnabled(mCheckBoxY.isChecked());
mFlipImageView.setRotationZEnabled(mCheckBoxZ.isChecked());
mFlipImageView.setRotationReversed(mCheckBoxReverse.isChecked()); //下面要设置监听器了
//FlipImageView.OnFlipListener
} /* (非 Javadoc)
* @see fr.castorflex.android.flipimageview.library.FlipImageView.OnFlipListener#onFlipStart(fr.castorflex.android.flipimageview.library.FlipImageView)
* 监听器
*/
@Override
public void onFlipStart(FlipImageView view) {
//开始翻转
mTextViewAnimationListener.setText("OnFlipStart");
} /* (非 Javadoc)
* @see fr.castorflex.android.flipimageview.library.FlipImageView.OnFlipListener#onFlipEnd(fr.castorflex.android.flipimageview.library.FlipImageView)
* 监听器
*/
@Override
public void onFlipEnd(FlipImageView view) {
//翻转结束
mTextViewAnimationListener.setText("OnFlipEnd");
} ////////////////////////SEEK BAR///////////////////////// @Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
mTextViewDuration.setText("" + progress);
} @Override
public void onStartTrackingTouch(SeekBar seekBar) {
} @Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
}

源码下载:http://download.csdn.net/detail/shark0017/7710153

用开源项目FlipImageView实现图片的翻转效果的更多相关文章

  1. css3图片3D翻转效果

    点击图片看翻转效果 html结构 <div class="flip"> <div class="front"> <img src= ...

  2. 基于jQuery遮罩图片hover翻转效果

    基于jQuery遮罩图片hover翻转效果.这是一款基于jQuery+css3实现的鼠标经过遮罩图片翻转特效.效果图如下: 在线预览   源码下载 实现的代码. html代码: <div cla ...

  3. 用开源项目CropImage实现图片的裁剪(不推荐)

       之前介绍过一个截图的办法(http://www.cnblogs.com/tianzhijiexian/p/3900241.html),这里再分享个开源项目.它也是截图,但是效果不是很好,首先还是 ...

  4. 用开源项目PhotoView实现图片的双指缩放和双击放大缩小

    项目地址:https://github.com/chrisbanes/PhotoView 用开源项目有个好处,一是实现简单,二是bug少.那么我们就来说下这个项目能够实现的效果: 1.单个图片的双指缩 ...

  5. CSS3之图片3D翻转效果(网页效果--每日一更)

    今天,带来的是纯CSS3的效果--图片3D翻转. 请看效果:亲,请点击这里 这个效果主要还是运用了CSS3的transform变形属性,与上个效果不同的是,这次并不是动画,所以没有采用animatio ...

  6. 图片触及翻转效果 css3

    实现图片由左向右飞入回到最初设定位置 ,鼠标浮上去旋转显示另一张图片效果: html: <!DOCTYPE HTML> <html> <head> <meta ...

  7. Android 开源项目分类汇总(转)

    Android 开源项目分类汇总(转) ## 第一部分 个性化控件(View)主要介绍那些不错个性化的 View,包括 ListView.ActionBar.Menu.ViewPager.Galler ...

  8. HTML和CSS实现图片翻转效果

    实现图片翻转,首先来分析一下我们希望实现的是怎样的翻转效果?又该如何去实现呢? 一.希望实现的效果 页面上的图片在光标悬停在上面的时候会发生翻转效果,翻转过后显示出背面的说明文字. 鼠标没有悬停在上面 ...

  9. Android 图片加载[常见开源项目汇总]

    该文主要是讲一下目前有哪些使用比较多的 图片加载开源项目,并简单介绍该如果使用 以及各开源项目之间有什么区别, 我们该如何去选择适合的开源项目应用到我们的项目中? 一.Android-Universa ...

随机推荐

  1. 使用GIT管理UE4代码

    在OSCHINA的GIT上创建远程项目 cd existing_git_repo git init git add Onepass/ Source/ notes.txt git commit -m & ...

  2. 记录一下SparkStreaming中因为使用redis做数据验证而导致数据结果不对的问题

    业务背景: 需要通过redis判断当前用户是否是新用户.当出现新用户后,会将该用户放入到redis中,以标明该用户已不是新用户啦. 出现问题: 发现入库时,并没有新用户入库,但我看了数据了,确实应该是 ...

  3. error 1044 (42000):access denied for user ''@'localhost' to database 'quickapp' 解决方法

    在虚拟机上重新创建一个数据库时,一直出现这个报错:error 1044 (42000):access denied for user ''@'localhost' to database 'quick ...

  4. Python - 计算个人所得税

    最近在学python,写了个计算个人所得税计算的脚本,分享. 以下为python3适用版本 #!/usr/bin/python # -*- coding: UTF-8 -*- # 该python脚本用 ...

  5. muduo学习笔记(二)Reactor关键结构

    目录 muduo学习笔记(二)Reactor关键结构 Reactor简述 什么是Reactor Reactor模型的优缺点 poll简述 poll使用样例 muduo Reactor关键结构 Chan ...

  6. Generator函数执行器-co函数库源码解析

    一.co函数是什么 co 函数库是著名程序员 TJ Holowaychuk 于2013年6月发布的一个小工具,用于 Generator 函数的自动执行.短小精悍只有短短200余行,就可以免去手动编写G ...

  7. 【Ray Tracing in One Weekend 超详解】 光线追踪1-1

    Preface 从这一篇起,我们开始学光线追踪这门牛逼的技术.读了几天,一个字:强! 这一篇我们主要讲述技术入门和一些简单的案例. 我们先学这本: Ready 这本书需要ppmview这个软件帮忙看效 ...

  8. 数据包编辑工具bittwiste

    数据包编辑工具bittwiste   bittwiste是数据包重放工具bittwist的一个工具.该工具可以编辑修改PCAP抓包文件.该工具提供数据包过滤功能,如根据范围和时间过滤.同时,该工具支持 ...

  9. java php c# 三种语言的AES加密互转

    java php c# 三种语言的AES加密互转 最近做的项目中有一个领取优惠券的功能,项目是用php写得,不得不佩服,php自带的方法简洁而又方便好用.项目是为平台为其他公司发放优惠券,结果很囧的是 ...

  10. centos7 打造基于python语言Selenium2自动化开发环境

    1. 准备 安装模块 # yum groupinstall "Development tools" # yum install zlib-devel bzip2-devel ope ...