所以,我創建了一個XML動畫:在我的佈局之一Android的自定義動畫原因InflateException
view_slider.xml :
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true"
android:duration="500"
android:fromYDelta="100%"
android:toYDelta="0%"
>
</translate>
現在我使用它:
Other Layout :
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:emoticon="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:foreground="@color/transparent"
android:layoutAnimation="@anim/**view_slider**"
>
<RelativeLayout
android:id="@+id/vox_full_content_relativeLayout"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/voxpop_background"
android:padding="5dp" >
.......
.......
而與此棧的應用程序崩潰:
08-18 17:34:54.180: E/AndroidRuntime(25482): FATAL EXCEPTION: main
08-18 17:34:54.180: E/AndroidRuntime(25482): android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.view.LayoutInflater.createView(LayoutInflater.java:620)
08-18 17:34:54.180: E/AndroidRuntime(25482): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.view.LayoutInflater.inflate(LayoutInflater.java:469)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
08-18 17:34:54.180: E/AndroidRuntime(25482): at com.jhamobi.yoapp.dashbaoard.Yo_local_msgs_list_fragment$VoxMsgItemsAdapter.getView(Yo_local_msgs_list_fragment.java:591)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.widget.AbsListView.obtainView(AbsListView.java:2177)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.widget.ListView.makeAndAddView(ListView.java:1840)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.widget.ListView.fillDown(ListView.java:675)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.widget.ListView.fillFromTop(ListView.java:736)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.widget.ListView.layoutChildren(ListView.java:1655)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.widget.AbsListView.onLayout(AbsListView.java:2012)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.view.View.layout(View.java:14296)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.view.ViewGroup.layout(ViewGroup.java:4562)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1076)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.view.View.layout(View.java:14296)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.view.ViewGroup.layout(ViewGroup.java:4562)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.view.View.layout(View.java:14296)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.view.ViewGroup.layout(ViewGroup.java:4562)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:907)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.view.View.layout(View.java:14296)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.view.ViewGroup.layout(ViewGroup.java:4562)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.view.View.layout(View.java:14296)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.view.ViewGroup.layout(ViewGroup.java:4562)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.support.v7.internal.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:493)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.view.View.layout(View.java:14296)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.view.ViewGroup.layout(ViewGroup.java:4562)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.view.View.layout(View.java:14296)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.view.ViewGroup.layout(ViewGroup.java:4562)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.view.View.layout(View.java:14296)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.view.ViewGroup.layout(ViewGroup.java:4562)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.view.View.layout(View.java:14296)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.view.ViewGroup.layout(ViewGroup.java:4562)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1976)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1730)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1004)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5481)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.view.Choreographer.doCallbacks(Choreographer.java:562)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.view.Choreographer.doFrame(Choreographer.java:532)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.os.Handler.handleCallback(Handler.java:730)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.os.Handler.dispatchMessage(Handler.java:92)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.os.Looper.loop(Looper.java:137)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.app.ActivityThread.main(ActivityThread.java:5289)
08-18 17:34:54.180: E/AndroidRuntime(25482): at java.lang.reflect.Method.invokeNative(Native Method)
08-18 17:34:54.180: E/AndroidRuntime(25482): at java.lang.reflect.Method.invoke(Method.java:525)
08-18 17:34:54.180: E/AndroidRuntime(25482): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
08-18 17:34:54.180: E/AndroidRuntime(25482): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
08-18 17:34:54.180: E/AndroidRuntime(25482): at dalvik.system.NativeStart.main(Native Method)
08-18 17:34:54.180: E/AndroidRuntime(25482): Caused by: java.lang.reflect.InvocationTargetException
08-18 17:34:54.180: E/AndroidRuntime(25482): at java.lang.reflect.Constructor.constructNative(Native Method)
08-18 17:34:54.180: E/AndroidRuntime(25482): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
08-18 17:34:54.180: E/AndroidRuntime(25482): at android.view.LayoutInflater.createView(LayoutInflater.java:594)
08-18 17:34:54.180: E/AndroidRuntime(25482): ... 57 more
08-18 17:34:54.180: E/AndroidRuntime(25482): Caused by: java.lang.RuntimeExcept
我在列表視圖中使用相同的xml文件,此處的佈局是該列表視圖的一個項目。這些動畫對於listview來說工作得很好。
此外,我使用的是appcompat v7庫。
如果我刪除android:layoutanimation
行,代碼工作正常。 我在做什麼錯了?
你申請AppCompatTheme到您的應用? – Prasad