2013-04-25 107 views
1

我正在開發另一個android應用程序。它確實有一個主菜單。現在它非常簡單 - 4個按鈕。現在我想讓該菜單的背景像動態壁紙一樣動畫。android動畫菜單背景

事實上,我只是想使用靜態背景圖像,並通過它橫向滑動1-2個其他圖像。我做了一些關於它的研究,發現動態壁紙帶有API 2.1。這完全符合我的需求,因爲應用程序應該與此API不兼容 - 當查看動畫時,RenderScript爲。想出了API 3.1,大多數教程都是基於這一點。

所以現在我只是失去了建議從哪裏開始。我讚賞每一種幫助!

爲勸我嘗試補間動畫 - 我幾乎跟着這個教程http://mobile.tutsplus.com/tutorials/android/android-sdk-creating-a-simple-tween-animation/

,並在仿真設備的工作像一個風情萬種..但是當我我的原生API 2.1設備上運行它沒有顯示動畫..我沒有考慮過的任何事情?

+1

要在屏幕上移動一個或兩個圖像並與Android 2兼容,您可以使用[Tween Animations](http://developer.android.com/guide/topics/graphics/view-animation.html)。他們不是一流的,但應該適合你所描述的。 – 2013-04-25 14:35:55

回答

1

首先感謝Class Stacker誰給我的建議去與吐溫動畫 - 這真的完全符合我的需求thx! - 不幸的是,動畫不在API 2.1設備上顯示。

下面這個Tuturial設置我的補間動畫「clouds_pass.xml」這樣的 -

<set xmlns:android="http://schemas.android.com/apk/res/android" 
android:shareInterpolator="false" 
android:duration="80000" 
android:interpolator="@android:anim/linear_interpolator" 
android:fillAfter="true" 
> 

<translate 
    android:fromXDelta="155%p" 
    android:toXDelta="-100%p" 
    android:repeatCount="infinite" 
/> 

的活動在呼喚這樣的吐溫 -

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 

    ImageView clouds = (ImageView)findViewById(R.id.clouds); 
    Animation cloudspass = AnimationUtils.loadAnimation(this,R.anim.clouds_pass); 
    clouds.startAnimation(cloudspass); 

} 

我不是defintly知道什麼可能是這個原因..但是從「clouds_pass.xml」中刪除android:duration標記並設置持續時間

cloudspass.setDuration(80000); 

在加載動畫之後修復了它 - 現在它可以按照預期工作到API 2.0設備。