android该怎么办iphone那种画面抖动的动画效果(含有button和EditText)
2023-09-11 14:21:01 时间
首先在效果图:
要做到抖动效果按钮,能够这样做。设定anim房源res以下。创建一个button_shake.xml
<?xml version="1.0" encoding="utf-8"?> <rotate xmlns:android="http://schemas.android.com/apk/res/android" android:duration="120" android:fromDegrees="-3" android:pivotX="100%" android:pivotY="100%" android:repeatCount="infinite" android:repeatMode="reverse" android:toDegrees="3" />
在代码里载入:
final ImageButton button = (ImageButton) findViewById(R.id.btn); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Animation shake = AnimationUtils.loadAnimation(AnimationTest.this, R.anim.button_shake); shake.reset(); shake.setFillAfter(true); button.startAnimation(shake); } });
给EditText做一个横向抖动的效果:
这样写anim的文件:
<?xml version="1.0" encoding="utf-8"?> <translate xmlns:android="http://schemas.android.com/apk/res/android" android:fromXDelta="0" android:toXDelta="10" android:duration="1300" android:interpolator="@anim/cycle" />
cycle.xml主要描写叙述动画的加速器:
<?xml version="1.0" encoding="utf-8"?> <!-- 动画从開始到结束,变化率是循环给定次数的正弦曲线。 --> <cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android" android:cycles="20" />
代码能够这样载入:
final Button confirm = (Button) findViewById(R.id.btn_confirm); confirm.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if(custom_edittext.getText().toString().equals("jake")){ Toast.makeText(AnimationTest.this, "welcome", Toast.LENGTH_LONG).show(); }else{ Animation shake = AnimationUtils.loadAnimation(AnimationTest.this, R.anim.shake_x); custom_edittext.startAnimation(shake); } } });
怎样给ListView加一个文字先后进入的动画:
<ListView android:id="@android:id/list" android:persistentDrawingCache="animation|scrolling" android:layout_width="match_parent" android:layout_height="match_parent" <span style="background-color: rgb(0, 153, 0);">android:layoutAnimation="@anim/layout_bottom_to_top_slide"</span> />
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android" android:delay="30%" android:animation="@anim/slide_right" /> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator"> <translate android:fromXDelta="-100%p" android:toXDelta="0" android:duration="@android:integer/config_shortAnimTime" /> </set>
代码能够在http://download.csdn.net/detail/baidu_nod/7616277下载
版权声明:本文博客原创文章。博客,未经同意,不得转载。
相关文章
- Android教程-android studio 制作.9 图片
- Android开发学习---android下的数据持久化,保存数据到rom文件,android_data目录下文件访问的权限控制
- Android网络游戏之神农诀项目开发--视频
- Android Animations动画使用详解
- 【备战2022】2020-2021 Android 腾讯面试真题总结(含参考答案)
- Android Framework 全面分析Zygote
- Android的报错提示:Failed to resolve: com.android.support.test.espresso:espresso-core:3.0.2
- Android 自定义点赞动画效果
- Android 多线程读写文件
- Android Interpolator属性 设置动画速度
- android布局中显示隐藏动画
- Android在程序中浏览网页
- android继续探索Fresco
- 【Android Gradle 插件】自定义 Gradle 插件模块 ⑤ ( 完整总结 ) ★★★
- Android培训班(68)dex文件打开流程
- Android系统设置— android.provider.Settings
- android电池充电动画,Android 开机充电图标和充电动画效果
- Android Spinner下拉框使用
- 迁移到Android后android.support.v4.content.FileProvider运行崩溃