arps
arps

Reputation: 417

Error:(3) Error parsing XML: not well-formed (invalid token)

This is my xml file inside then anim folder. When I run the app then an error in parsing is shown.

shake.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
< translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="1000"
    android:fromXDelta="0%"
    android:interpolator="@anim/cycle_7"
    android:toXDelta="5%" />
</set>

cycle_7.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
< cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
    android:cycles="7" />
</set>

Upvotes: 6

Views: 303

Answers (2)

Pratik Butani
Pratik Butani

Reputation: 62391

IT People Always Welcome Here you find full code that you are looking for.

shake.xml

<translate xmlns:android="http://schemas.android.com/apk/res/android" android:fromXDelta="0%" android:toXDelta="5%" android:duration="1000" android:interpolator="@anim/cycle_7" />

cycle_7.xml

<cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android" android:cycles="7" />

How to Use:

private void showError() {
      Animation shake = AnimationUtils.loadAnimation(this, R.anim.shake);
      mEditText.startAnimation(shake);
}

Edited:

  1. I think You have space between < and translate if you have copied code. Check it out.
  2. <set> is not required as i have run demo with my above code its working fine.

Thank you. May this will helpful you.

Upvotes: 5

Mohammed Aouf Zouag
Mohammed Aouf Zouag

Reputation: 17132

You are missing a closing </set> tag.

(+, delete that extra xmlns:android="http://schemas.android.com/apk/res/android" line from the inner elements)

Upvotes: 3

Related Questions