说翻译效果,从右到中,从中到左.请有人帮帮我.
public voID slIDShow(){ Runnable runnable = new Runnable() { @OverrIDe public voID run() { myslIDeshow(); handler.postDelayed(this,3000); } }; new Thread(runnable).start();}private voID myslIDeshow(){ Picposition = gallery.getSelectedItemposition() +1; if (Picposition >= bitmaps.size()){ Picposition = gallery.getSelectedItemposition(); //stop } else{ Animation inFromright = new TranslateAnimation( Animation.relative_TO_PARENT,+1.0f,Animation.relative_TO_PARENT,0.0f,0.0f); inFromright.setDuration(500); inFromright.setInterpolator(new AccelerateInterpolator()); gallery.startAnimation(inFromright); gallery.setSelection(Picposition); }}解决方法 使用基于Xml的动画
在文件夹res / anim / animate.xml中创建一个Xml文件
把代码
<set xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:shareInterpolator="true"> <translate androID:fromXDelta="0%p" androID:toXDelta="50%p" // change this to decIDe the range androID:duration="500" androID:startOffset="0"/> <translate androID:fromXDelta="0%p" androID:toXDelta="100%p" androID:duration="500" androID:startOffset="500"/>// change this to increase the time for image to stay </set>
现在你的函数myslIDeshow()改变了
Animation inFromright = AnimationUtils.loadAnimation(this,R.anim.animate);gallery.startAnimation(inFromright); gallery.setSelection(Picposition);
就这样…..
总结以上是内存溢出为你收集整理的Android画廊幻灯片动画全部内容,希望文章能够帮你解决Android画廊幻灯片动画所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)