【问题标题】:Error:(3) Error parsing XML: not well-formed (invalid token)错误:(3) 解析 XML 时出错:格式不正确(无效令牌)
【发布时间】:2015-12-31 21:34:53
【问题描述】:

这是我在 anim 文件夹中的 xml 文件。当我运行应用程序时,会显示解析错误。

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>

【问题讨论】:

  • 你可以看到我的答案。

标签: android xml


【解决方案1】:

IT People Always Welcome 在这里您可以找到您正在寻找的完整代码。

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" />

使用方法:

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

编辑:

  1. 如果您复制了代码,我认为您在 &lt;translate 之间有 空格。看看吧。
  2. &lt;set&gt; 不是必需的,因为我已经使用上面的代码运行了演示,它工作正常。

谢谢。希望对您有所帮助。

【讨论】:

  • 不,两个xml没有问题。可能你在其他xml中有另一个问题。可以发截图吗?
  • 谢谢..........实际上
【解决方案2】:

您缺少结束 &lt;/set&gt; 标记。

(+,从内部元素中删除多余的 xmlns:android="http://schemas.android.com/apk/res/android" 行)

【讨论】:

    猜你喜欢
    • 2015-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-25
    相关资源
    最近更新 更多