我把我的FAB的片段从活动中,我不断收到此错误:
10-01 21:01:55.238 22031-22031/com.vei.scanandgo E/AndroidRuntime:
FATAL EXCEPTION: main
Process: com.vei.scanandgo, PID: 22031
android.view.InflateException: Binary XML file line #408: Error inflating class android.support.design.widget.FloatingActionButton
at android.view.LayoutInflater.createView(LayoutInflater.java:620)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at com.vei.scanandgo.BaseFragment.storeView(BaseFragment.java:317)
. . .
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
. . .
. ...
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or descendant) with the design library.
at android.support.design.widget.ThemeUtils.checkAppCompatTheme(ThemeUtils.java:33)
at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:159)
at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:153)
. .
. ..
摇篮设为
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
充气是通过完成:
View mView = inflater.inflate(getlayoutResId(), container, false);
我没有唯一改变的是活性,AppCompatActivity将打了很多现有的代码。 我们有没有一种方法,使具有活性本FAB的工作?
FAB:
<android.support.design.widget.FloatingActionButton
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:src="@drawable/pichere"
app:backgroundTint="@color/white"
app:borderWidth="0dp" />
谢谢!
如果我作出了错误的设计,请告知还有什么我可以做,使与FAB的工作这个片段。