当前位置:网站首页>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" />

边栏推荐
- 【饭谈】如何设计好一款测试平台?
- A tour of grpc:03 - proto serialization / deserialization
- 【分布式理论】(一)分布式事务
- 【网络攻防原理与技术】第7章:口令攻击技术 第8章:网络监听技术
- With the latest Alibaba P7 technology system, mom doesn't have to worry about me looking for a job anymore
- LeetCode 648(C#)
- 【网络攻防原理与技术】第4章:网络扫描技术
- 跟奥巴马一起画方块(Lua)
- 99% 用户在 Power BI 云端报表常犯错误
- Several best practices for managing VDI
猜你喜欢

SIGGRAPH 2022最佳技术论文奖重磅出炉!北大陈宝权团队获荣誉提名

What is cloud computing?

99%的人都不知道|私有化部署还永久免费的即时通讯软件!

第3章业务功能开发(用户访问项目)

Devops' operational and commercial benefits Guide

科普达人丨一文弄懂什么是云计算?

mysql官网下载:Linux的mysql8.x版本(图文详解)

Mrs offline data analysis: process OBS data through Flink job

企业即时通讯软件是什么?它有哪些优势呢?

Linux 安装mysql8.X超详细图文教程
随机推荐
MRS离线数据分析:通过Flink作业处理OBS数据
Blue Bridge Cup final XOR conversion 100 points
L1-019 谁先倒(Lua)
企业即时通讯软件是什么?它有哪些优势呢?
How to add aplayer music player in blog
【饭谈】那些看似为公司着想,实际却很自私的故事 (一:造轮子)
2021-06-28
【分布式理论】(二)分布式存储
[source code interpretation] | source code interpretation of livelistenerbus
Matplotlib绘制三维图形
[image sensor] correlated double sampling CDs
Flash build API service
Sator a lancé le jeu web 3 "satorspace" et a lancé huobi
LeetCode1051(C#)
责任链模式 - Unity
自定义View必备知识,Android研发岗必问30+道高级面试题
Sator推出Web3遊戲“Satorspace” ,並上線Huobi
[video / audio data processing] Shanghai daoning brings you elecard download, trial and tutorial
【网络攻防原理与技术】第4章:网络扫描技术
99% 用户在 Power BI 云端报表常犯错误