当前位置:网站首页>viewflipper的功能和用法
viewflipper的功能和用法
2022-07-07 15:40:00 【XLMN】
viewflipper的功能和用法
viewflipper继承了viewanimator,可调用addview(view v)添加多个组件一旦向viewflipper添加多个组件之后,viewflipper就可以使用动画控制多个组件之间的切换效果
public class MainActivity extends Activity {
private ViewFlipper vf;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.viewflipper);
vf = (ViewFlipper) findViewById(R.layout.viewflipper);
}
public void prev(View view) {
// TODO Auto-generated method stub
vf.setInAnimation(this, android.R.anim.slide_in_left);
vf.setOutAnimation(this, android.R.anim.slide_out_right);
// 显示上一个组件
vf.showPrevious();
// 停止自动播放
vf.stopFlipping();
}
public void next(View view) {
// TODO Auto-generated method stub
vf.setInAnimation(this, android.R.anim.slide_in_left);
vf.setOutAnimation(this, android.R.anim.slide_out_right);
// 显示下一个
vf.showNext();
// 停止自动播放
vf.stopFlipping();
}
public void auto(View view) {
// TODO Auto-generated method stub
vf.setInAnimation(this, android.R.anim.slide_in_left);
vf.setOutAnimation(this,android.R.anim.slide_out_right);
// 开始自动播放
vf.startFlipping();
}
}
<?xml version="1.0" encoding="utf-8"?><!-- android:flipInterval="1000"意思就是设置里面每一个View显示的时间; -->
<ViewFlipper
android:id="@+id/viewflipper"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:flipInterval="1000" >
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/love" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/mia" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/mia10" />
</ViewFlipper>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:onClick="prev"
android:text="&lt" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:onClick="auto"
android:text="自动播放" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:onClick="next"
android:text="&gt" />

边栏推荐
- [Seaborn] combination chart: pairplot and jointplot
- 麒麟信安云平台全新升级!
- 本周小贴士131:特殊成员函数和`= default`
- How to implement safety practice in software development stage
- 2021-06-28
- 【饭谈】那些看似为公司着想,实际却很自私的故事 (一:造轮子)
- 【TPM2.0原理及应用指南】 5、7、8章
- 专精特新软件开发类企业实力指数发布,麒麟信安荣誉登榜
- mysql官网下载:Linux的mysql8.x版本(图文详解)
- User defined view essential knowledge, Android R & D post must ask 30+ advanced interview questions
猜你喜欢
随机推荐
【分布式理论】(二)分布式存储
LeetCode刷题day49
Sator推出Web3游戏“Satorspace” ,并上线Huobi
【TPM2.0原理及应用指南】 12、13、14章
redis主从、哨兵主备切换搭建一步一步图解实现
How to mount the original data disk without damage after the reinstallation of proxmox ve?
The top of slashdata developer tool is up to you!!!
第2章搭建CRM项目开发环境(数据库设计)
On Apache Doris Fe processing query SQL source code analysis
赋能智慧电力建设 | 麒麟信安高可用集群管理系统,保障用户关键业务连续性
Sator a lancé le jeu web 3 "satorspace" et a lancé huobi
Matplotlib绘图界面设置
Rpcms method of obtaining articles under the specified classification
本周小贴士#135:测试约定而不是实现
Leetcode brush questions day49
【视频/音频数据处理】上海道宁为您带来Elecard下载、试用、教程
[fan Tan] after the arrival of Web3.0, where should testers go? (ten predictions and suggestions)
第2章搭建CRM项目开发环境(搭建开发环境)
User defined view essential knowledge, Android R & D post must ask 30+ advanced interview questions
《世界粮食安全和营养状况》报告发布:2021年全球饥饿人口增至8.28亿








![[image sensor] correlated double sampling CDs](/img/1c/3a641ad47ff91536db602dedc82705.png)
