3.ViewFlipper的使用(上下翻滚轮播效果)
2016-03-24 15:49
337 查看
转载请注明出处 /article/9680829.html
本文出自:猴菇先生的博客
一种可以设置滑动动画的控件,只显示一行布局,在布局文件中的ViewFlipper控件中顺序写好每一行的布局
(1).MainActivity.java:
(2).activity_main.xml:
(3).push_up_in.xml:(动画资源文件)
push_up_out.xml:
本文出自:猴菇先生的博客
一种可以设置滑动动画的控件,只显示一行布局,在布局文件中的ViewFlipper控件中顺序写好每一行的布局
(1).MainActivity.java:
ViewFlipper mFlipper = ((ViewFlipper) this.findViewById(R.id.flipper)); mFlipper.startFlipping(); // 设置进入动画 mFlipper.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.push_up_in)); // 设置滚出动画 mFlipper.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.push_up_out));
(2).activity_main.xml:
<ViewFlipper android:id="@+id/flipper" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="20dip" android:flipInterval="3000" > // 设置滑动间隔时间(毫秒) <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" android:text="@string/animation_2_text_1" android:textSize="26sp" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" android:text="@string/animation_2_text_2" android:textSize="26sp" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" android:text="@string/animation_2_text_3" android:textSize="26sp" /> </ViewFlipper>
(3).push_up_in.xml:(动画资源文件)
<set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:fromYDelta="100%p" android:toYDelta="0" android:duration="300"/> <alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="300" /> </set>
push_up_out.xml:
<set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:fromYDelta="0" android:toYDelta="-100%p" android:duration="300"/> <alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="300" /> </set>
相关文章推荐
- 数据库范式——通俗易懂
- DP_硬币问题
- 设置带滚动条的TextView
- JS 实用技巧总结
- 有关IT行业模仿案例及自己的评价与解析:
- Java 后台sql注入
- linux命令---split
- IIS反向代理实现Revel域名访问
- 个人项目总结
- JavaScript之基础-2 JavaScript 变量、常量
- 写一个备份文件的python脚本
- eclipse+hadoop 配置过程中遇到的问题
- TCP与UDP的区别
- android WebView详解
- eclipse+hadoop 配置过程中遇到的问题
- linux shell 统计不同文件扩展名的个数
- response.setHeader——禁用IE缓存
- jQuery制作无缝轮播的焦点图
- mysqldump: Couldn't execute 'SET OPTION SQL_QUOTE_SHOW_CREATE=1': You have an error in your SQL syntax; check the manual t
- T-SQL XQuery (XML路径查询) (转)http://blog.csdn.net/Beirut/article/details/8150116