android数字滚动效果实现
上一篇 /
下一篇 2015-11-04 17:15:21
/ 个人分类:step by step android测试
ps:做的过程中又熟悉了的几个关键属性:android:gravity=“center” 居中android:includeFontPadding=“false" 去掉text size自带的padding值android:layout_toRightOf="@id/XXX”LinearLayout中以另外一个元素为基准来设置padding值
以下是正文:onFinishInflate中对动画进行定义赋值,一个滚出去的动画,一个滚上来的动画。在oncreate方法里面对需要滚动的元素设置动画效果。<?xml version="1.0"encoding="utf-8"?><setxmlns:android="http://schemas.android.com/apk/res/android"]]> <translateandroid:fromYDelta="100%p"android:toYDelta="0"android:duration="300"/> <alphaandroid:fromAlpha="0.0"android:toAlpha="1.0"android:duration="300"/></set]]>
<?xml version="1.0"encoding="utf-8"?><setxmlns:android="http://schemas.android.com/apk/res/android"]]>
<translateandroid:fromYDelta="0"android:toYDelta="-100%p"android:duration="300"/>
<alphaandroid:fromAlpha="1.0"android:toAlpha="0.0"android:duration="300"/></set]]>
上下滚动的话,需要定义2个一模一样的textview,但是通过GONE与VISIBLE来控制textview的显示区域。元素就会交替展示啦。
自己定义事件来调用滚动的函数就好。
private voidshowCountAnimation() {
//第一个可见时
if(A.getVisibility() == View.VISIBLE) { if(A.getAnimation() ==mInAnimation) {
A.clearAnimation();
}
A.startAnimation(mOutAnimation); A.setVisibility(View.GONE);
if(B.getAnimation() ==mOutAnimation) {
B.clearAnimation();
}
B.setText("1111"); B.startAnimation(mInAnimation); B.setVisibility(View.VISIBLE);
}
else{
if(A.getAnimation() ==mOutAnimation) {
A.clearAnimation();
}
A.setText("2222"); A.startAnimation(mInAnimation); A.setVisibility(View.VISIBLE);
if(B.getAnimation() ==mInAnimation) {
B.clearAnimation();
}
B.startAnimation(mOutAnimation); B.setVisibility(View.GONE);
}
}
相关阅读:
- MonkeyRunner Recorder&PlayBack (zaza9084, 2015-11-06)
- 导入MonkeyRunner模块失败的处理方法 (zaza9084, 2015-11-06)
- MonkeyRunner内置uiautomator出错的原因 (zaza9084, 2015-11-09)
- MonkeyRunner创建一个Note的实例 (zaza9084, 2015-11-11)
- MonkeyRunner-andrec实现思路 (zaza9084, 2015-11-13)
- Monkeyrunner得id查找方法 (zaza9084, 2015-11-13)
- MonkeyRunner实例讲解 (zaza9084, 2015-11-12)
- MonkeyRunner的初级程序 (zaza9084, 2015-11-12)
- MonkeyRunner连接指定设备 (zaza9084, 2015-11-12)
- MonkeyRunner浅谈和入门 (zaza9084, 2015-11-12)
收藏
举报
TAG:
Android
android