[英]How to animate to a specific position of a gallery
我想移動到帶有動畫的畫廊中的特定位置。 例如,我在圖庫中有100個元素,實際位置是0。我想緩慢移動(動畫)到位置99。
我嘗試了以下命令,這似乎很有希望。 但它不設置動畫:-(
gallery.setSelection(int position, boolean animate)
有什么提示嗎?
也許您必須使用這樣的東西:創建animate.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"/>
並在您的代碼中使用以下代碼:
Animation inFromRight = AnimationUtils.loadAnimation(this, R.anim.animate);
gallery.startAnimation(inFromRight);
gallery.setSelection(PicPosition);
這個想法來自這個鏈接:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.