我创建了一个广告控件,其中包括ViewSwitcher...
在该控件中,我有ImageView和TextView,因为广告要么是文本,要么是图像。
现在我必须给广告添加动画效果...
我尝试过以下方法
inAnimation = AnimationUtils.loadAnimation(this,android.R.anim.slide_in_left); inAnimation.setDuration(1500);
outAnimation = AnimationUtils.loadAnimation(this,android.R.anim.slide_out_right); outAnimation.setDuration(1500);
然后将其设置为开关器
ViewSwitcher switcher; switcher.setInAnimation(inAnimation); switcher.setOutAnimation(outAnimation);
但它不起作用。
请给我任何其他替代方案。或者如果使用上述代码错误,则如何使用它?
在该控件中,我有ImageView和TextView,因为广告要么是文本,要么是图像。
现在我必须给广告添加动画效果...
我尝试过以下方法
inAnimation = AnimationUtils.loadAnimation(this,android.R.anim.slide_in_left); inAnimation.setDuration(1500);
outAnimation = AnimationUtils.loadAnimation(this,android.R.anim.slide_out_right); outAnimation.setDuration(1500);
然后将其设置为开关器
ViewSwitcher switcher; switcher.setInAnimation(inAnimation); switcher.setOutAnimation(outAnimation);
但它不起作用。
请给我任何其他替代方案。或者如果使用上述代码错误,则如何使用它?
"@android:anim/slide_in_up"
和"@android:anim/slide_out_down"
。如果你收到错误信息“Resource is not public”,请参考https://dev59.com/Gmsz5IYBdhLWcg3wQFi2#8019405。 - Juuso Ohtonenandroid:rotation
,再将您的内容嵌套在更低一层的布局中,并使用相反方向的android:rotation
。 - Aiden Strydom