- 浏览: 2144433 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (1240)
- mac/IOS (287)
- flutter (1)
- J2EE (115)
- android基础知识 (582)
- android中级知识 (55)
- android组件(Widget)开发 (18)
- android 错误 (21)
- javascript (18)
- linux (70)
- 树莓派 (18)
- gwt/gxt (1)
- 工具(IDE)/包(jar) (18)
- web前端 (17)
- java 算法 (8)
- 其它 (5)
- chrome (7)
- 数据库 (8)
- 经济/金融 (0)
- english (2)
- HTML5 (7)
- 网络安全 (14)
- 设计欣赏/设计窗 (8)
- 汇编/C (8)
- 工具类 (4)
- 游戏 (5)
- 开发频道 (5)
- Android OpenGL (1)
- 科学 (4)
- 运维 (0)
- 好东西 (6)
- 美食 (1)
最新评论
-
liangzai_cool:
请教一下,文中,shell、C、Python三种方式控制led ...
树莓派 - MAX7219 -
jiazimo:
...
Kafka源码分析-序列5 -Producer -RecordAccumulator队列分析 -
hp321:
Windows该命令是不是需要安装什么软件才可以?我试过不行( ...
ImageIO读jpg的时候出现javax.imageio.IIOException: Unsupported Image Type -
hp321:
Chenzh_758 写道其实直接用一下代码就可以解决了:JP ...
ImageIO读jpg的时候出现javax.imageio.IIOException: Unsupported Image Type -
huanghonhpeng:
大哥你真强什么都会,研究研究。。。。小弟在这里学到了很多知识。 ...
android 浏览器
先来看效果:
上面为两个按钮,点击对应的按钮,绿色背景会滚动到相应的按钮后面
点击红色方块会有反转效果,仿照win8磁铁的效果
下面是代码
ScrollAnimation.java
RotateAnimation.java
MainActivity.java
main.xml
上面为两个按钮,点击对应的按钮,绿色背景会滚动到相应的按钮后面
点击红色方块会有反转效果,仿照win8磁铁的效果
下面是代码
ScrollAnimation.java
package com.iaiai.activity; import android.graphics.Camera; import android.graphics.Matrix; import android.util.Log; import android.view.View; import android.view.animation.Animation; import android.view.animation.LinearInterpolator; import android.view.animation.Transformation; /** * * <br/> * Title: ScrollAnimation.java<br/> * E-Mail: 176291935@qq.com<br/> * QQ: 176291935<br/> * Http: iaiai.iteye.com<br/> * Create time: 2013-2-19 上午10:53:06<br/> * <br/> * * @author 丸子 * @version 0.0.1 */ public class ScrollAnimation extends Animation { private View view; private Camera camera = new Camera(); private boolean direction = true; // true往右,false往左 public ScrollAnimation(View view, boolean direction) { this.view = view; this.direction = direction; } @Override public void initialize(int width, int height, int parentWidth, int parentHeight) { super.initialize(width, height, parentWidth, parentHeight); setDuration(300); setFillAfter(true); setFillBefore(true); setInterpolator(new LinearInterpolator()); } protected void applyTransformation(float interpolatedTime, Transformation transformation) { Matrix matrix = transformation.getMatrix(); camera.save(); if (direction) { camera.translate(interpolatedTime * view.getWidth(), 0.0f, 0); } else { camera.translate(view.getWidth() - (interpolatedTime * view.getWidth()), 0.0f, 0); } camera.getMatrix(matrix); camera.restore(); } }
RotateAnimation.java
package com.iaiai.activity; import android.graphics.Camera; import android.graphics.Matrix; import android.view.View; import android.view.animation.Animation; import android.view.animation.Transformation; /** * * <br/> * Title: RotateAnimation.java<br/> * E-Mail: 176291935@qq.com<br/> * QQ: 176291935<br/> * Http: iaiai.iteye.com<br/> * Create time: 2013-2-19 上午10:07:57<br/> * <br/> * * @author 丸子 * @version 0.0.1 */ public class RotateAnimation extends Animation { /** 值为true时可明确查看动画的旋转方向。 */ public static final boolean DEBUG = false; /** 沿Y轴正方向看,数值减1时动画逆时针旋转。 */ public static final boolean ROTATE_DECREASE = true; /** 沿Y轴正方向看,数值减1时动画顺时针旋转。 */ public static final boolean ROTATE_INCREASE = false; /** Z轴上最大深度。 */ public static final float DEPTH_Z = 310.0f; /** 动画显示时长。 */ public static final long DURATION = 800l; /** 图片翻转类型。 */ private final boolean type; private final float centerX; private final float centerY; private Camera camera; /** 用于监听动画进度。当值过半时需更新txtNumber的内容。 */ private InterpolatedTimeListener listener; public RotateAnimation(View view, boolean type) { centerX = view.getWidth() / 2.0f; centerY = view.getHeight() / 2.0f; this.type = type; setDuration(DURATION); } public void initialize(int width, int height, int parentWidth, int parentHeight) { // 在构造函数之后、getTransformation()之前调用本方法。 super.initialize(width, height, parentWidth, parentHeight); camera = new Camera(); } public void setInterpolatedTimeListener(InterpolatedTimeListener listener) { this.listener = listener; } protected void applyTransformation(float interpolatedTime, Transformation transformation) { // interpolatedTime:动画进度值,范围为[0.0f,10.f] if (listener != null) { listener.interpolatedTime(interpolatedTime); } float from = 0.0f, to = 0.0f; if (type == ROTATE_DECREASE) { from = 0.0f; to = 180.0f; } else if (type == ROTATE_INCREASE) { from = 360.0f; to = 180.0f; } float degree = from + (to - from) * interpolatedTime; boolean overHalf = (interpolatedTime > 0.5f); if (overHalf) { // 翻转过半的情况下,为保证数字仍为可读的文字而非镜面效果的文字,需翻转180度。 degree = degree - 180; } // float depth = 0.0f; float depth = (0.5f - Math.abs(interpolatedTime - 0.5f)) * DEPTH_Z; final Matrix matrix = transformation.getMatrix(); camera.save(); camera.translate(0.0f, 0.0f, depth); camera.rotateY(degree); camera.getMatrix(matrix); camera.restore(); if (DEBUG) { if (overHalf) { matrix.preTranslate(-centerX * 2, -centerY); matrix.postTranslate(centerX * 2, centerY); } } else { // 确保图片的翻转过程一直处于组件的中心点位置 matrix.preTranslate(-centerX, -centerY); matrix.postTranslate(centerX, centerY); } } /** 动画进度监听器。 */ public static interface InterpolatedTimeListener { public void interpolatedTime(float interpolatedTime); } }
MainActivity.java
package com.iaiai.activity; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.view.animation.AnimationUtils; import android.widget.TextView; import com.iaiai.activity.RotateAnimation.InterpolatedTimeListener; public class MainActivity extends Activity implements OnClickListener, InterpolatedTimeListener { private boolean bol = true; private boolean enableRefresh; private int number = 0; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); findViewById(R.id.btn1).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (!bol) findViewById(R.id.tv).startAnimation(new ScrollAnimation(findViewById(R.id.tv), false)); bol = true; } }); findViewById(R.id.btn2).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (bol) findViewById(R.id.tv).startAnimation(new ScrollAnimation(findViewById(R.id.tv), true)); bol = false; } }); findViewById(R.id.layout1).setOnClickListener(this); } public void onClick(View v) { enableRefresh = true; RotateAnimation rotateAnim = null; if (bol) { number--; rotateAnim = new RotateAnimation(findViewById(R.id.layout1), RotateAnimation.ROTATE_DECREASE); } else { number++; rotateAnim = new RotateAnimation(findViewById(R.id.layout1), RotateAnimation.ROTATE_INCREASE); } if (rotateAnim != null) { rotateAnim.setInterpolatedTimeListener(this); rotateAnim.setFillAfter(true); findViewById(R.id.layout1).startAnimation(rotateAnim); } } @Override public void interpolatedTime(float interpolatedTime) { // 监听到翻转进度过半时,更新txtNumber显示内容。 if (enableRefresh && interpolatedTime > 0.5f) { ((TextView) findViewById(R.id.ltv)).setText(Integer.toString(number)); enableRefresh = false; } } }
main.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@android:color/white" android:orientation="vertical" > <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingBottom="10dip" android:paddingLeft="20dip" android:paddingRight="20dip" android:paddingTop="10dip" > <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" > <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <TextView android:id="@+id/tv" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:background="#00ff00" /> <TextView android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:textColor="@android:color/black" android:textSize="20dip" android:visibility="invisible" /> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <TextView android:id="@+id/btn1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:gravity="center" android:text="左旋转" android:textColor="@android:color/black" android:textSize="20dip" /> <TextView android:id="@+id/btn2" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:gravity="center" android:text="右旋转" android:textColor="@android:color/black" android:textSize="20dip" /> </LinearLayout> </RelativeLayout> </LinearLayout> <LinearLayout android:id="@+id/layout1" android:layout_width="150dip" android:layout_height="150dip" android:background="#ff0000" > <TextView android:id="@+id/ltv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="文字" android:textColor="@android:color/white" android:textSize="20dip" /> </LinearLayout> </LinearLayout>
发表评论
-
带你深入理解 FLUTTER 中的字体“冷”知识
2020-08-10 23:40 565本篇将带你深入理解 Flutter 开发过程中关于字体和文 ... -
Flutter -自定义日历组件
2020-03-01 17:56 1021颜色文件和屏幕适配的文件 可以自己给定 import ... -
Dart高级(一)——泛型与Json To Bean
2020-02-23 19:13 923从 Flutter 发布到现在, 越来越多人开始尝试使用 Da ... -
flutter loading、Progress进度条
2020-02-21 17:03 1029Flutter Progress 1 条形无固定值进度条 ... -
Flutter使用Https加载图片
2020-02-21 01:39 898Flutter使用Https加载图片 使用http加载图片出 ... -
flutter shared_preferences 异步变同步
2020-02-21 00:55 762前言 引用 在开发原生iOS或Native应用时,一般有判断上 ... -
Flutter TextField边框颜色
2020-02-19 21:31 849监听要销毁 myController.dispose(); T ... -
flutter Future的正确用法
2020-02-18 21:55 725在flutter中经常会用到异步任务,dart中异步任务异步处 ... -
记一次Flutter简单粗暴处理HTTPS证书检验方法
2020-02-18 14:13 822最近在做Flutter项目到了遇到一个无解的事情,当使用Ima ... -
flutter 获取屏幕宽度高度 通知栏高度等屏幕信息
2019-07-27 08:39 1221##MediaQuery MediaQuery.of(con ... -
关于flutter RefreshIndicator扩展listview下拉刷新的问题
2019-07-10 19:40 995当条目过少时listview某些嵌套情况下可能不会滚动(条目 ... -
flutter listview 改变状态的时候一直无限添加
2019-07-10 16:01 671setstate的时候会一直无限的调用listview.bui ... -
Flutter Android端启动白屏问题的解决
2019-07-09 00:51 1399问题描述 Flutter 应用在 Android 端上启动时 ... -
Flutter中SnackBar使用
2019-07-08 23:43 676底部弹出,然后在指定时间后消失。 注意: build(Bui ... -
Flutter 之点击空白区域收起键盘
2019-07-08 18:43 1656点击空白处取消TextField焦点这个需求是非常简单的,在学 ... -
Flutter 弹窗 Dialog ,AlertDialog,IOS风格
2019-07-08 18:04 1287import 'package:flutter/mate ... -
flutter ---TextField 之 输入类型、长度限制
2019-07-08 14:30 2196TextField想要实现输入类型、长度限制需要先引入impo ... -
【flutter 溢出BUG】键盘上显示bottom overflowed by 104 PIXELS
2019-07-08 11:13 1443一开始直接使用Scaffold布局,body:new Colu ... -
解决Flutter项目卡在Initializing gradle...界面的问题
2019-07-07 12:53 787Flutter最近很火,我抽出了一点时间对Flutter进行了 ... -
关于android O 上 NotificationChannel 的一些注意事项
2019-07-04 11:47 884最近在适配android O,遇到个问题,应用中原本有设置界面 ...
相关推荐
Android 点击出现水波纹效果,支持两种布局LinearLayout和RelativeLayout
在Android里面,一些炫酷的动画确实是很吸引人的地方,让然看了就赏心悦目,一个好看的动画可能会提高用户对软件的使用率。另外说到动画,在Android里面...首先看一下本文要实现的动画效果:手指向上移动到开关按钮处,
目的:动画效果可以让用户的体验感非常好。在“演示Android中的文字和图片特效控件的使用”资源中,讲是的TextSwitcher控件、Gallery控件和ImageSwitcher控件的特效实现。而这个资源演示的是android的动画编程,本...
较简单的实现,有不足和实现的不到位的还请指教 ...属性动画处两种实现方式,注释中都有说明 学习和实现主要参考博客 http://blog.csdn.net/harvic880925?viewmode=contents 中自定义控件三部曲之动画篇的前面几篇
在Android中,帧动画的本质是把一组预先准备好的图片循环切换播放,造成一种动画效果。 帧动画实现 实现帧动画有两种方式,即xml和java 方法1:xml实现帧动画 第一步:导入帧动画素材 把准备的素材放到drawable目录...
Android中一共提供了两种动画,其一便是tween动画,tween动画通过对view的内容进行一系列的图像变换(包括平移,缩放,旋转,改变透明度)来实现动画效果,动画效果的定义可以使用xml,也可以使用编码来实现。...
之前说过了在Android中,动画Animation的实现有两种方式:Tween Animation(渐变动画)和Frame Animation(帧动画)。渐变动画是通过对场景里的对象不断做图像变换(平移、缩放、旋转等)产生动画效果。帧动画则是...
在Android中,动画Animation的实现有两种方式:Tween Animation(补间动画)和Frame Animation(帧动画)。渐变动画是通过对场景里的对象不断做图像变换(平移、缩放、旋转等)产生动画效果。帧动画则是通过顺序播放...
按钮移动用两种方法实现:tween动画和property动画
Android 动画效果二 Frame Animation 动画专题研究 Android新浪客户端开发教程(完整版)汇总大全 Android多媒体实例大汇集(源码,全) Android中利用画图类和线程画出闪烁的心形,送给亲爱的他 android自带的示例...
多种Tab切换的动画效果实现底部导航中间按钮凸出的效果实现WeChat那种滑动导航的底部渐变效果,随着滑动的距离变化而变化实现TabBar上的红色标记,并且可以拖动强大的BadgeView功能,智能判断数字隐藏与越界显示,两种...
第1章 Android的系统介绍5 1.1 系统介绍5 1.2 软件结构和使用的工具7 第2章 Android SDK的开发环境10 2.1 Android SDK的结构10 2.2 Android SDK环境安装11 2.2.1. 安装JDK基本Java环境11 ...10.4 3D动画效果的实现129
较简单的实现,有不足和实现的不到位的还请指教 ...属性动画处两种实现方式,注释中都有说明 学习和实现主要参考博客 http://blog.csdn.net/harvic880925?viewmode=contents 中自定义控件三部曲之动画篇的前面几篇
View的z值由两部分组成,elevation和translationZ(它们都是Android L新引入的属性)。 eleavation是静态的成员,translationZ是用来做动画。 Z = elevation + translationZ 在layout中使用* andr
作为使用androidsdk构建这些应用程序的实用指南书籍,《android高级编程》从始至终穿插了一系列示例项目,每个项目都引入android的新功能和新技术,以助您达到最圆满的学习效果。书中介绍android的所有基本功能,并...
----------------------------------- Android 编程基础 1 封面----------------------------------- Android 编程基础 2 开放手机联盟 --Open --Open --Open --Open Handset Handset Handset Handset Alliance ...
16.3.3 使用Camera实现2D图像的深度效果 16.3.4 探索AnimationListener类 16.3.5 关于变换矩阵的一些说明 16.4 资源 16.5 小结 第17章 地图和基于位置的服务 17.1 地图包 17.1.1 从Google获取...
功能可通过布局xml文件进行完全配置可以附着到布局中的任何视图自动调整附着位置两种fab大小(“正常”和“小”)很好的显示和触摸动画使用示例要将FabView附着到目标视图,请执行以下操作:下列的。 用FrameLayout...