2014-06-10 1 views
0

알림 바에서 애니메이션을 제어 할 수 있습니까?알림 바에서 애니메이션을 구동

그릴 수 xml 파일 : /drawable/tracker_animation.xml

<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false"> 
    <item android:drawable="@drawable/user_location_on" android:duration="1000" /> 
    <item android:drawable="@drawable/user_location_on_blick" android:duration="1000" /> 
</animation-list> 

및 알림 빌더로 설정 :

은이 코드를 사용하여 간단한 깜박임을 할 수 있었다
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) 
        .setSmallIcon(R.drawable.tracker_animation); 

이제 애니메이션을 제어하고 싶습니다. 예를 들어 새로운 좌표가있을 때만 그것을 실행하십시오. 또는 좌표를 서버에 보냅니다.

나는

android:oneshot="true" 

를 설정하고 내가 원하는 경우 수동으로 시작 애니메이션 애니메이션 드로어 블 AnimationDrawable을 얻을 싶어요. 는 다른 뷰를 위해이 같은 일을 :

ImageView img = (ImageView)findViewById(R.id.spinning_wheel_image); 
img.setBackgroundResource(R.drawable.spin_animation); 

// 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(); 

하지만이 NotificationManager에서 나는 그것이 잘못된 방향이었다이 목적을 위해 애니메이션의 .getBackground()

답변

0

사용을 할 수 없습니다.

더 잘 사용하려면 LevelListDrawable입니다. 하지만 어쩌면 아주 좋은하지 난 그냥 인터넷과의 상호 작용은 그래서 아주 간단하게 보여줄 필요가 내 경우에 code.google.com

에 설명 된 문제 만이 있습니다

전에 요청

을 실행을 GET 응답 콜백 후
mBuilder.setSmallIcon(R.drawable.user_location_on_blick); 
Notification notification = mBuilder.build(); 
mNotificationManager.notify(notificationId, notification); 

mBuilder.setSmallIcon(R.drawable.user_location_on); 
Notification notification = mBuilder.build(); 
mNotificationManager.notify(notificationId, notification);