Unable to implement FloatingActionButton

I am using a library published by James Montemagno @ https://github.com/jamesmontemagno/FloatingActionButton-for-Xamarin.Android

I tried to implement the FloatingActionButton with the following code.

ConversationList.axml:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:fab="http://schemas.android.com/apk/res-auto" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ListView android:id="@+id/ConversationsListView" android:layout_width="match_parent" android:layout_height="match_parent" android:choiceMode="singleChoice" /> <com.refractored.fab.FloatingActionButton android:id="@+id/CreateConversationFAB" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|right" android:layout_margin="16dp" android:src="@drawable/ic_add_white_24dp" fab:fab_size="mini" fab:fab_shadow="true" fab:fab_colorNormal="@color/azulito" fab:fab_colorPressed="@color/azulito" /> </LinearLayout>

ConversationListActivity.cs:
var content = (ViewGroup)FindViewById (global::Android.Resource.Id.Content); var conversationsView = GetInflatedConversationsView (content);
View GetInflatedConversationsView(ViewGroup view){ return this.LayoutInflater.Inflate(Resource.Layout.ConversationsList, view, true); }

When I get to the las block of code I posted I get the following error:

Unable to start activity ComponentInfo{com.messenger.android/md523d1f0d00e20a3d104edb3cf78d3b2ee.ConversationsListActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class com.refractored.fab.FloatingActionButton

And in the Application Output I detected this:
Caused by: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: System.TypeLoadException: Could not load type 'Android.Graphics.Drawables.RippleDrawable' from assembly 'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9fra79065'.

Posts

  • YkshLeoYkshLeo USMember ✭✭✭✭

    Try this Sample :blush:

  • JamesMontemagnoJamesMontemagno USForum Administrator, Xamarin Team, Developer Group Leader Xamurai
    edited July 2015

    You should actually now use the official Floating Action Button: https://components.xamarin.com/view/xamandroidsupportdesign

    See the sample in there. It looks like you might not be setting your target and compile to 21. Also, you should put that into a FrameLayout and not a LinearLayout.

  • WilliamRaifordWilliamRaiford USMember ✭✭
    edited August 2015

    @JamesMontemagno Does it matter if I use the NuGet package versus the component? I would prefer the NuGet package, as it allows for easier updating. Also, it does not seem to want to be added via the component route in my Android Library project (though it adds to the Android application itself just fine). After adding and removing from the application, it does add to the library project now. The Edit Components dialog seems to be having problems, which is just further reason for me to want to just use NuGet if possible.

  • CheesebaronCheesebaron DKInsider, University mod

    The NuGet contains the same stuff as the component except for the samples and documentation a component might come with.

  • JamesMontemagnoJamesMontemagno USForum Administrator, Xamarin Team, Developer Group Leader Xamurai

    Yup, you can do either of them.

  • IkyMasieIkyMasie BWMember ✭✭

    Im yet to find a working solution... i still get the error inflating the FAB

    Help???

  • @IkyMasie Try adding this attribute to the root node of your layout: xmlns:tools="http://schemas.android.com/tools"

    For example:
    <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.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="@dimen/fab_margin" android:src="@android:drawable/fab_icon" /> </LinearLayout >

  • NinineaNininea USUniversity ✭✭✭

    I have same problem in api 15 (using nuget package) any solution?

  • SourcephySourcephy USMember

    I remove FloatingActionButton instead use CircleButton, I need to support lower version of Andriod

  • MohammedismailsameerMohammedismailsameer USMember ✭✭
    edited November 14

    hi nininea,
    i have used floating action button in my code snippet.
    but null exception occur when floating button click for call to web api in xamarin forms.
    please let me know,how to resolve this issue?

Sign In or Register to comment.