当前位置:网站首页>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" />
边栏推荐
- 本周小贴士#135:测试约定而不是实现
- 浅谈 Apache Doris FE 处理查询 SQL 源码解析
- Repair method of firewall system crash and file loss, material cost 0 yuan
- PLC: automatically correct the data set noise, wash the data set | ICLR 2021 spotlight
- Leetcode brush questions day49
- 99% 用户在 Power BI 云端报表常犯错误
- Mysql 索引命中级别分析
- 让保险更“保险”!麒麟信安一云多芯云桌面中标中国人寿, 助力金融保险信息技术创新发展
- Matplotlib绘图界面设置
- 99%的人都不知道|私有化部署还永久免费的即时通讯软件!
猜你喜欢
随机推荐
使用 xml资源文件定义菜单
【分布式理论】(一)分布式事务
阿富汗临时政府安全部队对极端组织“伊斯兰国”一处藏匿点展开军事行动
User defined view essential knowledge, Android R & D post must ask 30+ advanced interview questions
DevOps 的运营和商业利益指南
策略模式 - Unity
【信息安全法律法規】複習篇
第3章业务功能开发(实现记住账号密码)
麒麟信安云平台全新升级!
Enum + Validation 的个人最佳实践 demo 分享
麒麟信安操作系统衍生产品解决方案 | 存储多路径管理系统,有效提高数据传输可靠性
【饭谈】Web3.0到来后,测试人员该何去何从?(十条预言和建议)
Flask搭建api服务-生成API文档
Sator推出Web3遊戲“Satorspace” ,並上線Huobi
LeetCode 497(C#)
大笨钟(Lua)
PLC: automatically correct the data set noise, wash the data set | ICLR 2021 spotlight
赋能智慧电力建设 | 麒麟信安高可用集群管理系统,保障用户关键业务连续性
Reflections on "product managers must read: five classic innovative thinking models"
Siggraph 2022 best technical paper award comes out! Chen Baoquan team of Peking University was nominated for honorary nomination