EMI*_*MIN 46 android android-animation
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.vitesse);
gpsManager = new GPSManager();
gpsManager.startListening(getApplicationContext());
gpsManager.setGPSCallback(this);
Typeface tf = Typeface.createFromAsset(getAssets(),
"font/DS-DIGI.TTF");
TextView loding =(TextView)findViewById(R.id.info_message);
loding.setTypeface(tf);
AlphaAnimation fadeIn = new AlphaAnimation(0.0f , 1.0f ) ;
AlphaAnimation fadeOut = new AlphaAnimation( 1.0f , 0.0f ) ;
loding.startAnimation(fadeIn);
loding.startAnimation(fadeOut);
fadeIn.setDuration(500);
fadeOut.setDuration(1200);
fadeOut.setStartOffset(1200+fadeIn.getStartOffset()+1200);
measurement_index = AppSettings.getMeasureUnit(this);
}
Run Code Online (Sandbox Code Playgroud)
我想重复一下textview loding动画,直到从GPS获取信息
ale*_*lex 107
像这样.
animation.setRepeatCount(Animation.INFINITE);
Run Code Online (Sandbox Code Playgroud)
vog*_*Dev 17
Android为您提供了优雅的机制来表示加载过程.您可以使用不确定的ProgressBar,或ImageView使用缩放/ alpha动画,而不是动画TextView自身.
也许你会发现这个动画很有用,可以同时为alpha和scale制作动画.根据您的偏好改变参数:
file R.anim.alpha_scale_animation
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<scale
android:fromXScale="0.7"
android:toXScale="1.0"
android:fromYScale="0.7"
android:toYScale="1.0"
android:pivotX="50%p"
android:pivotY="50%p"
android:duration="4000"
android:repeatCount="infinite"
/>
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="2000"
android:repeatMode="reverse"
android:repeatCount="infinite"
/>
</set>
Run Code Online (Sandbox Code Playgroud)
然后在你的代码中启动它:
Animation connectingAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.alpha_scale_animation);
myView.startAnimation(connectingAnimation);
Run Code Online (Sandbox Code Playgroud)
并阻止它:
myView.clearAnimation();
connectingAnimation.cancel();
connectingAnimation.reset();
Run Code Online (Sandbox Code Playgroud)
您还可以使用ProgressButtonView等库来在同一个窗口小部件中同时支持用户交互和加载过程.
希望这些解决方案对任何人都有用:)
fadeIn.setRepeatCount(int count)
fadeIn.setRepeatMode(AlphaAnimation.INFINITE(or any other repeat mode reletaed yo your usage))
Run Code Online (Sandbox Code Playgroud)
你可以使用这些方法来控制重复.
如果需要,实现这个
//anim = your animation
anim.setAnimationListener(new AnimationListener()
{
public void onAnimationStart(Animation arg0)
{
// TODO Auto-generated method stub
}
public void onAnimationRepeat(Animation arg0)
{
// TODO Auto-generated method stub
}
public void onAnimationEnd(Animation arg0)
{
}
});
Run Code Online (Sandbox Code Playgroud)
如果你想突然停止你的动画.使用yourview.clearAnimation()我希望这会有所帮助.
小智 5
要重复动画,只需在 xml 文件中添加代码,该文件位于我们创建动画对象的 anim 文件夹文件中。
| 归档时间: |
|
| 查看次数: |
68509 次 |
| 最近记录: |