android - View added from github library dont work

I wont to use nice Floating Action Button to my project. I want to use some libraries from github. I like this FAB: https://github.com/Clans/FloatingActionButton . I added dependences to gradle.app file:

compile 'com.github.clans:fab:1.6.2'

But my application does not work and crash. XML:

<com.github.clans.fab.FloatingActionButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/plus"
        android:layout_gravity="bottom|right"
        android:layout_marginBottom="8dp"
        android:layout_marginRight="8dp"
        app:fab_colorNormal="#DA4336"
        app:fab_colorPressed="#E75043"
        app:fab_colorRipple="#99FFFFFF"
        app:fab_showShadow="true"
        app:fab_shadowColor="#66000000"
        app:fab_shadowRadius="4dp"
        app:fab_shadowXOffset="1dp"
        app:fab_shadowYOffset="3dp"
        app:fab_size="normal"
        />

LogCat:

FATAL EXCEPTION: main
Process: com.poltavets.app.howtodraw, PID: 31836
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.poltavets.app.howtodraw/com.poltavets.app.howtodraw.view.HowTo}: android.view.InflateException: Binary XML file line #23: Error inflating class com.github.clans.fab.FloatingActionButton
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2462)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2524)
at android.app.ActivityThread.access$800(ActivityThread.java:167)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1419)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5546)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759)
Caused by: android.view.InflateException: Binary XML file line #23: Error inflating class com.github.clans.fab.FloatingActionButton
at android.view.LayoutInflater.createView(LayoutInflater.java:637)

Line 23 of xml is:

 <com.github.clans.fab.FloatingActionButton

Java:

public class HowTo extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.howtodraw);
    }
}

In ANDROID STUDIOS ITs works: How i can fix it?

enter image description here

1 Answer

  1. Brent- Reply

    2019-11-14

    as per the library have you included line in your main parent layout ?

    xmlns:fab="http://schemas.android.com/apk/res-auto"
    

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>