Added a FloatingActionButton to the markup:

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <ListView android:id="@+id/lvMain" android:layout_weight="1" android:layout_width="match_parent" android:layout_height="match_parent"> </ListView> <android.support.design.widget.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|end" android:layout_margin="16dp" android:src="@drawable/pl"> </android.support.design.widget.FloatingActionButton> </LinearLayout> 

Displays error:

android.view.InflateException: Binary XML file line # 31: Error inflating class android.support.design.widget.FloatingActionButton

Help to understand the problem, I will be very grateful.

  • Well, in the first place , да и унаследоваться от sure that 'com.android.support:design is connected , да и унаследоваться от it would not hurt to , да и унаследоваться от AppCompatActivity` - ermak0ff
  • 'com.android.support:design is connected dependencies {compile fileTree (dir:' libs ', include: [' * .jar ']) compile "com.android.support:support-v4:23.1.0" compile' com. android.support:design:22.2.0 '} - roma
  • Well, Activity extends AppCompatActivity ? - ermak0ff
  • MainActivity extends the FragmentActivity using fragments - roma
  • You also need support-v7 connect - YuriySPb

2 answers 2

In Android Studia, when you create a new project, one of the options comes with the FloatingActionButton . Launch and compare with yours.

  • would compare, like what I need, there are no differences - roma

Try to set the version of all libraries to the maximum. Gradle should look something like this ( buildToolsVersion also needs to take the last one and not forget about the name of your package (applicationId)):

 apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.1" defaultConfig { applicationId "ТУТ.ВАШ.ПАКЕТ" minSdkVersion 15 targetSdkVersion 23 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:23.0.1' compile 'com.android.support:design:23.0.1' compile 'com.android.support:support-v4:23.0.1' } 
  • I don’t know what happened, but I went on my own)) but anyway, thanks!)) - roma
  • Most likely it was in the old version of the design . I think if you check your project now with the line compile 'com.android.support:design:22.2.0' then it will fall again with your error. - Yuriy SPb
  • No, there was originally a compile'com.android.support: design: 22.2.0 'version, but I tried the new version, the application crashed with errors Error: (1) : TextAppearance.Material.Widget.Button.Inverse '. Error: (1) Error retrieving the found name android: Widget.Material.Button.Colored ' - roma
  • one
    The support-v4 library @roma is connected to the appcompat-v7 library as a dependency , it does not need to be connected separately again in this case. - pavlofff