Android 在xml中扩展类集时出错
我试图创建一个Android 在xml中扩展类集时出错,android,android-layout,android-animation,Android,Android Layout,Android Animation,我试图创建一个textView,它会在屏幕上滑动,并产生错误,但我不知道为什么。这是我的xml: <set xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent"
textView
,它会在屏幕上滑动,并产生错误,但我不知道为什么。这是我的xml:
<set xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillAfter="true">
<scale
android:duration="500"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:interpolator="@android:anim/linear_interpolator"
android:toXScale="1.0"
android:toYScale="0.0" />
<TextView
android:id="@+id/scroll_message"
android:text="@string/scroll_text"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:minLines="1"
android:maxLines="10"
android:width="250dp"
android:textColor="@android:color/black"
android:textStyle="bold" />
</set>
给出的错误是:
09-10 09:02:47.117 31292-31292/com.example.rsa.myapplication E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.rsa.myapplication, PID: 31292
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.rsa.myapplication/com.example.rsa.myapplication.MyActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class set
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2255)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2317)
at android.app.ActivityThread.access$800(ActivityThread.java:143)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1258)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5070)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:836)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:631)
Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class set
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:753)
at android.view.LayoutInflater.inflate(LayoutInflater.java:478)
at android.view.LayoutInflater.inflate(LayoutInflater.java:410)
at android.view.LayoutInflater.inflate(LayoutInflater.java:361)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:350)
at android.app.Activity.setContentView(Activity.java:2122)
at com.example.ranjeev.myapplication.MyActivity.onCreate(MyActivity.java:23)
at android.app.Activity.performCreate(Activity.java:5720)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1102)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2208)
什么会导致这个错误
使用代码中的动画集,如下所示:
public void onResume(){
super.onResume();
textView.startAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.slide_up));
}
您好……当我使用此代码时,它会在
R.anim.slide\u up
上出错,并说“错误:找不到符号变量anim
我假设您将动画集保存在anim
资源文件夹中,作为名为slide\u up.xml
的xml文件。你应该认真阅读《Android开发者指南》中的动画:不,名为activity\u my
的xml文件在布局文件夹中。创建anim
文件夹仍会显示相同的错误。
public void onResume(){
super.onResume();
textView.startAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.slide_up));
}