Error inflating class android.support.design.widget.CoordinatorLayout

后端 未结 13 1591
甜味超标
甜味超标 2020-12-08 09:39

I would like use a FloatingActionButton on my application, I read this : https://guides.codepath.com/android/Floating-Action-Buttons#google-s-official-support-library but wh

相关标签:
13条回答
  • 2020-12-08 10:28

    Add these dependencies into your gradle file. This may solve the problem in some cases.

    dependencies {
       compile 'com.android.support:appcompat-v7:23.1.1'
       compile 'com.android.support:design:23.1.1'
       ...
    }
    
    0 讨论(0)
  • 2020-12-08 10:33

    For those using AndroidX Dependency

    Along with changing dependencies, XML must also be changed.

    from

    <android.support.design.widget.CoordinatorLayout 
    

    to

    <androidx.coordinatorlayout.widget.CoordinatorLayout
    
    0 讨论(0)
  • 2020-12-08 10:39

    I had the same error. Just change the project parent theme to

    <style name="Base.AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    

    or any other Theme.AppCompat*

    0 讨论(0)
  • 2020-12-08 10:41

    Please put compile 'com.android.support:design:23.0.1' inside your project build.gradle file

    0 讨论(0)
  • 2020-12-08 10:42

    Just use this line in FloatingActionButton (app instead of android):

    app:backgroundTint="@color/colorAccent"
    
    0 讨论(0)
  • 2020-12-08 10:42

    For Xamarin Developers:

    (supports Android API 7 to 22+)

    1. Make sure you have installed following components:
      • Android Support Design Library
      • Android Support Library v7 AppCompat
    2. Make sure all NuGet packages for these components are installed and referenced. These are:
      • Xamarin.Android.Support.Design
      • Xamarin.Android.Support.v4
      • Xamarin.Android.Support.v7.AppCompat
      • Xamarin.Android.Support.v7.RecyclerView
    3. Your Apps Activity should derive from Android.Support.V7.App.AppCompatActivity
    4. Your used style has to be derived from a Theme.AppCompat.* style. So your Resources\values\styles.xml should look like this:

      <?xml version="1.0" encoding="utf-8"?>
      <resources>
          <style name="YourAppTheme" parent="Theme.AppCompat">
              <item name="colorPrimaryDark">#AB000D</item>
              <item name="colorPrimary">#E53935</item>
              <item name="colorAccent">#00B8D4</item>
          </style>
          <!-- other styles... -->
      </resources>
      
    5. Also make sure you actually use the theme in your AndroidManifest.xml

      <application android:theme="@style/YourAppTheme"></application>
      
    0 讨论(0)
提交回复
热议问题