无法使浮动操作按钮

时间:2016-12-17 12:37:14

标签: android material-design floating-action-button

这是我的布局文件:

<?xml version="1.0" encoding="utf-8"?>

    <android.support.design.widget.CoordinatorLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
            <android.support.design.widget.AppBarLayout
             android:id="@+id/app_bar_layout"
             android:layout_width="match_parent"
             android:layout_height="wrap_content">

    <android.support.v7.widget.Toolbar
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/primaryColor"
        android:minHeight="?attr/actionBarSize"
        app:layout_scrollFlags="enterAlways"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        app:theme="@style/ToolbarTheme"/>

    <android.support.design.widget.TabLayout
        android:id="@+id/sliding_tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/primaryColor"
        android:minHeight="?attr/actionBarSize"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        app:tabGravity="fill"
        app:tabIndicatorColor="@android:color/white"
        app:tabIndicatorHeight="4dp"
        app:tabMode="fixed"/>
</android.support.design.widget.AppBarLayout>

<android.support.v4.view.ViewPager
    android:id="@+id/viewpager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

   <android.support.design.widget.FloatingActionButton
    android:id="@+id/fabButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="end|bottom"
    android:layout_margin="16dp"
    android:src="@drawable/ic_av_videocam_white"
    android:visibility="gone"
    app:backgroundTint="@color/primaryColor"
    app:borderWidth="0dp"
    app:elevation="6dp"
    app:layout_anchorGravity="bottom|right|end"/>

</android.support.design.widget.CoordinatorLayout>

Style.xml代码:

    

<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/primaryColor</item>
    <item name="colorPrimaryDark">@color/primaryColorDark</item>
    <item name="colorAccent">@color/accentColor</item>
    <item name="android:dialogTheme">@style/CustomDialog</item>
    <!--<item name="android:windowFullscreen">true</item>-->
</style>

<style name="AppTheme.Base.FullScreen" parent="AppTheme.Base">
    <!--<item name="colorPrimaryDark">@color/grey_100</item>-->
    <item name="android:windowFullscreen">true</item>
</style>

Gradle文件:

compileSdkVersion 23
buildToolsVersion "23.0.3"

dexOptions {
    jumboMode true
}

defaultConfig {
    applicationId "in.co.memoize"
    minSdkVersion 15
    targetSdkVersion 22
    versionCode 14
    versionName "1.13"

    renderscriptTargetApi 19
    renderscriptSupportModeEnabled true
}

compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:percent:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.google.android.gms:play-services-gcm:8.3.0'
compile 'com.google.android.gms:play-services-plus:8.3.0'
compile 'com.google.android.gms:play-services-analytics:8.3.0'

获取错误&#34;无法实例化以下类: android.support.design.widget.FloatingActionButton&#34;

堆栈追踪:

java.lang.NoSuchMethodError:android.support.v7.widget.AppCompatImageHelper。(Landroid / widget / ImageView; Landroid / support / v7 / widget / AppCompatDrawableManager;)V     在android.support.design.widget.FloatingActionButton。(FloatingActionButton.java:133)     在android.support.design.widget.FloatingActionButton。(FloatingActionButton.java:110)     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)     在org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:465)     在org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:172)     在org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:105)     在com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:176)     在android.view.BridgeInflater.loadCustomView(BridgeInflater.java:247)     在android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:171)     在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)     在android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:835)     在android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)     在android.view.LayoutInflater.rInflate(LayoutInflater.java:811)     在android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)     在android.view.LayoutInflater.inflate(LayoutInflater.java:515)     在android.view.LayoutInflater.inflate(LayoutInflater.java:394)     在com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:229)     在com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:426)     在com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)     在com.android.tools.idea.rendering.RenderTask $ 2.compute(RenderTask.java:520)     在com.android.tools.idea.rendering.RenderTask $ 2.compute(RenderTask.java:508)     在com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:967)     在com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:508)     在com.android.tools.idea.rendering.RenderTask.access $ 600(RenderTask.java:75)     在com.android.tools.idea.rendering.RenderTask $ 3.call(RenderTask.java:620)     在com.android.tools.idea.rendering.RenderTask $ 3.call(RenderTask.java:617)     在com.android.tools.idea.rendering.RenderService.runRenderAction(RenderService.java:371)     在com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:617)     在com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:639)     在com.intellij.android.designer.designSurface.AndroidDesignerEditorPanel $ 7.run(AndroidDesignerEditorPanel.java:519)     在com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:337)     在com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:327)     在com.intellij.util.ui.update.MergingUpdateQueue $ 3.run(MergingUpdateQueue.java:271)     在com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:286)     在com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:244)     在com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:234)     在com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)     在com.intellij.util.Alarm $ Request $ 1.run(Alarm.java:352)     at java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:511)     at java.util.concurrent.FutureTask.run(FutureTask.java:266)     在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)     at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)     在java.lang.Thread.run(Thread.java:745)

我已经尝试了之前问题的所有建议。似乎没有解决这个问题..请帮助..

0 个答案:

没有答案