1

I want to set the blink animation, in the compound drawable(left) of textview.

i followed the link: http://chiuki.github.io/advanced-android-textview/#/4

its helped me and also working like a charm. but, i failed to achieve blink animation, please guide me for the correct approach.

the xml file i used for blink animation is as follows:

blink_anim.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha android:fromAlpha="0.0"
    android:toAlpha="1.0"
    android:interpolator="@android:anim/accelerate_interpolator"
    android:duration="600"
    android:repeatMode="reverse"
    android:repeatCount="infinite"/>

and pointed this xml in textview, like this:

android:drawableLeft="@drawable/blink_anim"

but it throws exception, the logcat view:

02-27 07:24:34.533: E/AndroidRuntime(1128): FATAL EXCEPTION: main
02-27 07:24:34.533: E/AndroidRuntime(1128): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.animation.app/com.animation.app.MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class <unknown>
02-27 07:24:34.533: E/AndroidRuntime(1128):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at android.os.Looper.loop(Looper.java:137)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at android.app.ActivityThread.main(ActivityThread.java:5103)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at java.lang.reflect.Method.invokeNative(Native Method)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at java.lang.reflect.Method.invoke(Method.java:525)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at dalvik.system.NativeStart.main(Native Method)
02-27 07:24:34.533: E/AndroidRuntime(1128): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class <unknown>
02-27 07:24:34.533: E/AndroidRuntime(1128):     at android.view.LayoutInflater.createView(LayoutInflater.java:620)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at android.app.Activity.setContentView(Activity.java:1895)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at android.support.v7.app.ActionBarActivityDelegateICS.setContentView(ActionBarActivityDelegateICS.java:110)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at com.animation.app.MainActivity.onCreate(MainActivity.java:18)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at android.app.Activity.performCreate(Activity.java:5133)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
02-27 07:24:34.533: E/AndroidRuntime(1128):     ... 11 more
02-27 07:24:34.533: E/AndroidRuntime(1128): Caused by: java.lang.reflect.InvocationTargetException
02-27 07:24:34.533: E/AndroidRuntime(1128):     at java.lang.reflect.Constructor.constructNative(Native Method)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at android.view.LayoutInflater.createView(LayoutInflater.java:594)
02-27 07:24:34.533: E/AndroidRuntime(1128):     ... 27 more
02-27 07:24:34.533: E/AndroidRuntime(1128): Caused by: android.content.res.Resources$NotFoundException: File res/drawable/blink_animation.xml from drawable resource ID #0x7f020059
02-27 07:24:34.533: E/AndroidRuntime(1128):     at android.content.res.Resources.loadDrawable(Resources.java:2091)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at android.widget.TextView.<init>(TextView.java:802)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at android.widget.TextView.<init>(TextView.java:614)
02-27 07:24:34.533: E/AndroidRuntime(1128):     ... 30 more
02-27 07:24:34.533: E/AndroidRuntime(1128): Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #2: invalid drawable tag set
02-27 07:24:34.533: E/AndroidRuntime(1128):     at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:897)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at android.graphics.drawable.Drawable.createFromXml(Drawable.java:837)
02-27 07:24:34.533: E/AndroidRuntime(1128):     at android.content.res.Resources.loadDrawable(Resources.java:2087)
02-27 07:24:34.533: E/AndroidRuntime(1128):     ... 33 more
Anggrayudi H
  • 14,977
  • 11
  • 54
  • 87
AlexR
  • 15
  • 6
  • can you upload your drawable xml and java file? – Siva Feb 27 '15 at 07:16
  • You need to provide some more details. Have you had a look at [this question](http://stackoverflow.com/q/10326170/983430) to see whether it may solve your problem? – Amos M. Carpenter Feb 27 '15 at 07:18
  • @Amos M. Carpenter, link which you provided is to set the animation over the button itself, as i mentioned in the post, i need to apply animation over the compound drawable. – AlexR Feb 27 '15 at 07:31

1 Answers1

0
Binary XML file line #2: invalid drawable tag set

Tells you that you can't have <alpha tag in drawable. The link that you referenced to, have

<animation-list>
  <item android:drawable="@drawable/ic_wifi_0"
      android:duration="250" />
  <item android:drawable="@drawable/ic_wifi_1"
      android:duration="250" />
  <item android:drawable="@drawable/ic_wifi_2"
      android:duration="250" />
  <item android:drawable="@drawable/ic_wifi_3"
      android:duration="250" />
</animation-list>

Which is different kind of animation, so you need to created those drawables by yourself and list them in animation-list

Roger Alien
  • 3,040
  • 1
  • 36
  • 46