2014-07-27 3 views
0

내 앱이 첫 번째 화면을로드 할 때 비치 파도가 들리는 애니메이션을 추가하려고합니다. 휴가 앱을 개발 중이며 이미 이미지 (모래의 정적 이미지)을 배경으로 사용합니다. 모래 이미지를 배경으로하고 파도가 해안에 부딪히는 효과를 기대합니다. 어떻게 이것을 달성해야합니까? 이 그림에서 움직임이있는 물결을 원합니다 ->http://www.wallpapervortex.com/wallpaper-23493_beach_sand_sand_beach.html#.U9Rr2fldW8AAndroid 앱에서 애니메이션 효과를 배경으로 가져 오는 방법은 무엇인가요?

+0

당신은 VideoView를 지켜 보면서을 사용하는 생각? –

+0

@harvey_slash VideoView 클래스를 거친 후 필자는 필자의 요구 사항에 적합하지 않다고 생각합니다. MediaController와 함께 VideoView를 사용하면 이러한 기능이 필요하지 않지만 일시 중지 할 수있는 옵션이 제공됩니다. – Sri

답변

0

각 프레임을 드로어 블 폴더에 별도의 이미지로 만듭니다. 그 후, (예를 들어, ANIMATED.xml)

<animation-list android:id="@+id/selected" android:oneshot="false"> 
    <item android:drawable="@drawable/0" android:duration="50" /> 
    <item android:drawable="@drawable/1" android:duration="50" /> 
    <item android:drawable="@drawable/2" android:duration="50" /> 
    <item android:drawable="@drawable/3" android:duration="50" /> 
    <item android:drawable="@drawable/4" android:duration="50" /> 
    <item android:drawable="@drawable/5" android:duration="50" /> 
</animation-list> 

그리고 애니메이션을 만들 수있는 프레임을 정의하기 위해 XML을 사용하여, 이것을 사용 :

// Load the ImageView that will host the animation and 
// set its background to our AnimationDrawable XML resource. 
ImageView img = (ImageView)findViewById(R.id.moving_image); 
img.setBackgroundResource(R.drawable.ANIMATED.xml); 

// Get the background, which has been compiled to an AnimationDrawable object. 
AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground(); 

// Start the animation (looped playback by default). 
frameAnimation.start();