2014-02-28 40 views
0

我應該顯示一個從左到右繪製線條的動畫。請看下面的圖片。android,如何從左到右掃動alpha動畫?

  • 第一層是背景(圖像整體沒有根線和國名)
  • 第二層是線和國名。

我可以用在我的活動方式如下奧飛動漫:

mIvRoot = (ImageView) findViewById(R.id.ivRoot); 
ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(mIvRoot, "alpha", 0f, 1f); 
alphaAnim.setDuration(2000); 
alphaAnim.start(); 

雖然它工作正常,但是阿爾法適用於整個圖像。我正在尋找的東西是阿爾法從左到右適用。因此,用戶感覺線條正在繪製。

任何建議,將不勝感激。由於

enter image description here

回答

0

即使我不明白你爲什麼不畫這些線,你可能想看看Romain Guy的this post,他也做了類似的事情(其實幾乎相同:))

+1

似乎這是我的問題的答案。謝謝Yahya。 – Hesam

1

我在bl.sht方式暫時固定我的問題。請與我分享你的想法來解決這個問題。

我對根圖像的頂部放置在另一個白色視圖(因爲我的背景是白色的),並分配它翻譯動畫,而不是使用阿爾法動畫像這樣:

<View 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@color/White" 
       android:id="@+id/viCover" 
       android:layout_alignTop="@+id/ivRoot" 
       android:layout_alignBottom="@+id/ivRoot" 
       android:layout_alignLeft="@+id/ivRoot" 
       android:layout_alignRight="@+id/ivRoot" 
       android:layout_marginLeft="200dp"/> 

和代碼:

ObjectAnimator transRootAnim = ObjectAnimator.ofFloat(mViCover, "translationX", 0f, 1500f); 
transRootAnim.setDuration(3000); 
transRootAnim.start();