Android控件Tween动画(补间动画)实现方法示例

Android控件Tween动画(补间动画)实现方法示例,第1张

概述本文实例讲述了Android控件Tween动画(补间动画)实现方法。分享给大家供大家参考,具体如下:

本文实例讲述了AndroID控件Tween动画(补间动画)实现方法。分享给大家供大家参考,具体如下:

AndroID动画中的Tween动画:是把控件对象不断的进行图像变化来产生旋转、平移、放缩和渐变等动画效果。

@H_419_7@/** * 控件Tween动画 * * @description: * @author ldm * @date 2016-6-22 下午5:26:24 */public class TweenActivity extends Activity { private Seekbar seekbarX;// 拖动条控件 private Seekbar seekbarY; private Seekbar scaleSeekbarX; private Seekbar scaleSeekbarY; private Seekbar rotationSeekbarX; private Seekbar rotationSeekbarY; private Seekbar rotationSeekbarZ; private button button; @OverrIDe public voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_tween); initVIEws(); initEvents(); } /** * * @description:初始化控件 * @author ldm * @date 2016-6-22 下午5:26:26 */ private voID initVIEws() { button = (button) findVIEwByID(R.ID.button); seekbarX = (Seekbar) findVIEwByID(R.ID.translationX); seekbarX.setMax(400); seekbarY = (Seekbar) findVIEwByID(R.ID.translationY); seekbarY.setMax(800); scaleSeekbarX = (Seekbar) findVIEwByID(R.ID.scaleX); scaleSeekbarX.setMax(50); scaleSeekbarX.setProgress(10); scaleSeekbarY = (Seekbar) findVIEwByID(R.ID.scaleY); scaleSeekbarY.setMax(50); scaleSeekbarY.setProgress(10); rotationSeekbarX = (Seekbar) findVIEwByID(R.ID.rotationX); rotationSeekbarX.setMax(360); rotationSeekbarY = (Seekbar) findVIEwByID(R.ID.rotationY); rotationSeekbarY.setMax(360); rotationSeekbarZ = (Seekbar) findVIEwByID(R.ID.rotationZ); rotationSeekbarZ.setMax(360); } /** * * @description:控件设置监听事件 * @author ldm * @date 2016-6-22 下午5:26:26 */ private voID initEvents() { // 按钮X方向平移动画 seekbarX.setonSeekbarchangelistener(new Seekbar.OnSeekbarchangelistener() { public voID onStopTrackingtouch(Seekbar seekbar) { } public voID onStartTrackingtouch(Seekbar seekbar) { } public voID onProgressChanged(Seekbar seekbar,int progress,boolean fromUser) { // X方向平移 button.setTranslationX((float) progress); } }); // 按钮Y方向平移动画 seekbarY.setonSeekbarchangelistener(new Seekbar.OnSeekbarchangelistener() { public voID onStopTrackingtouch(Seekbar seekbar) { } public voID onStartTrackingtouch(Seekbar seekbar) { } public voID onProgressChanged(Seekbar seekbar,boolean fromUser) { // Y方向平移 button.setTranslationY((float) progress); } }); // 按钮X方向缩放动画 scaleSeekbarX .setonSeekbarchangelistener(new Seekbar.OnSeekbarchangelistener() { public voID onStopTrackingtouch(Seekbar seekbar) { } public voID onStartTrackingtouch(Seekbar seekbar) { } public voID onProgressChanged(Seekbar seekbar,boolean fromUser) { // X方向缩放 button.setScaleX((float) progress / 10f); } }); // 按钮Y方向缩放动画 scaleSeekbarY .setonSeekbarchangelistener(new Seekbar.OnSeekbarchangelistener() { public voID onStopTrackingtouch(Seekbar seekbar) { } public voID onStartTrackingtouch(Seekbar seekbar) { } public voID onProgressChanged(Seekbar seekbar,boolean fromUser) { // Y方向缩放 button.setScaleY((float) progress / 10f); } }); // 按钮X方向旋转动画 rotationSeekbarX .setonSeekbarchangelistener(new Seekbar.OnSeekbarchangelistener() { public voID onStopTrackingtouch(Seekbar seekbar) { } public voID onStartTrackingtouch(Seekbar seekbar) { } public voID onProgressChanged(Seekbar seekbar,boolean fromUser) { // X方向旋转 button.setRotationX((float) progress); } }); // 按钮Y方向旋转动画 rotationSeekbarY .setonSeekbarchangelistener(new Seekbar.OnSeekbarchangelistener() { public voID onStopTrackingtouch(Seekbar seekbar) { } public voID onStartTrackingtouch(Seekbar seekbar) { } public voID onProgressChanged(Seekbar seekbar,boolean fromUser) { // Y方向旋转 button.setRotationY((float) progress); } }); // 按钮Z方向旋转动画 rotationSeekbarZ .setonSeekbarchangelistener(new Seekbar.OnSeekbarchangelistener() { public voID onStopTrackingtouch(Seekbar seekbar) { } public voID onStartTrackingtouch(Seekbar seekbar) { } public voID onProgressChanged(Seekbar seekbar,boolean fromUser) { // 设置旋转 button.setRotation((float) progress); } }); }}

布局文件R.layout.activity_tween

<?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"  androID:ID="@+ID/container"  androID:layout_wIDth="match_parent"  androID:layout_height="match_parent"  androID:orIEntation="vertical"  androID:splitMotionEvents="true" >  <linearLayout    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content"    androID:layout_margintop="20dip"    androID:orIEntation="horizontal"    androID:splitMotionEvents="true" >    <TextVIEw      androID:layout_wIDth="wrap_content"      androID:layout_height="wrap_content"      androID:paddingleft="5dip"      androID:paddingRight="5dip"      androID:text="TX"      androID:textStyle="bold" />    <Seekbar      androID:ID="@+ID/translationX"      androID:layout_wIDth="match_parent"      androID:layout_height="wrap_content"      androID:layout_weight="1"      androID:orIEntation="horizontal" />    <TextVIEw      androID:layout_wIDth="wrap_content"      androID:layout_height="wrap_content"      androID:paddingleft="15dip"      androID:paddingRight="5dip"      androID:text="TY"      androID:textStyle="bold" />    <Seekbar      androID:ID="@+ID/translationY"      androID:layout_wIDth="match_parent"      androID:layout_height="wrap_content"      androID:layout_weight="1"      androID:orIEntation="horizontal" />  </linearLayout>  <linearLayout    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content"    androID:layout_margintop="20dip"    androID:orIEntation="horizontal"    androID:splitMotionEvents="true" >    <TextVIEw      androID:layout_wIDth="wrap_content"      androID:layout_height="wrap_content"      androID:paddingleft="5dip"      androID:paddingRight="5dip"      androID:text="SX"      androID:textStyle="bold" />    <Seekbar      androID:ID="@+ID/scaleX"      androID:layout_wIDth="wrap_content"      androID:layout_height="wrap_content"      androID:layout_weight="1"      androID:orIEntation="horizontal" />    <TextVIEw      androID:layout_wIDth="wrap_content"      androID:layout_height="wrap_content"      androID:paddingleft="15dip"      androID:paddingRight="5dip"      androID:text="SY"      androID:textStyle="bold" />    <Seekbar      androID:ID="@+ID/scaleY"      androID:layout_wIDth="wrap_content"      androID:layout_height="wrap_content"      androID:layout_weight="1"      androID:orIEntation="horizontal" />  </linearLayout>  <linearLayout    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content"    androID:layout_margintop="20dip"    androID:orIEntation="horizontal"    androID:splitMotionEvents="true" >    <TextVIEw      androID:layout_wIDth="wrap_content"      androID:layout_height="wrap_content"      androID:paddingleft="5dip"      androID:paddingRight="5dip"      androID:text="X"      androID:textStyle="bold" />    <Seekbar      androID:ID="@+ID/rotationX"      androID:layout_wIDth="match_parent"      androID:layout_height="wrap_content"      androID:layout_weight="1"      androID:orIEntation="horizontal" />    <TextVIEw      androID:layout_wIDth="wrap_content"      androID:layout_height="wrap_content"      androID:paddingleft="15dip"      androID:paddingRight="5dip"      androID:text="Y"      androID:textStyle="bold" />    <Seekbar      androID:ID="@+ID/rotationY"      androID:layout_wIDth="match_parent"      androID:layout_height="wrap_content"      androID:layout_weight="1"      androID:orIEntation="horizontal" />    <TextVIEw      androID:layout_wIDth="wrap_content"      androID:layout_height="wrap_content"      androID:paddingleft="15dip"      androID:paddingRight="5dip"      androID:text="Z"      androID:textStyle="bold" />    <Seekbar      androID:ID="@+ID/rotationZ"      androID:layout_wIDth="match_parent"      androID:layout_height="wrap_content"      androID:layout_weight="1"      androID:orIEntation="horizontal" />  </linearLayout>  <button    androID:ID="@+ID/rotatingbutton"    androID:layout_wIDth="200dip"    androID:layout_height="150dip"    androID:layout_marginleft="50dip"    androID:layout_margintop="50dip"    androID:text="Rotating button" /></linearLayout>

更多关于AndroID相关内容感兴趣的读者可查看本站专题:《Android开发动画技巧汇总》、《Android开发入门与进阶教程》、《Android视图View技巧总结》、《Android编程之activity *** 作技巧总结》、《Android文件 *** 作技巧汇总》、《Android资源 *** 作技巧汇总》及《Android控件用法总结》

希望本文所述对大家AndroID程序设计有所帮助。

总结

以上是内存溢出为你收集整理的Android控件Tween动画(补间动画)实现方法示例全部内容,希望文章能够帮你解决Android控件Tween动画(补间动画)实现方法示例所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1144808.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-31
下一篇2022-05-31

发表评论

登录后才能评论

评论列表(0条)

    保存