Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Problems implementing Floating Action Buttons on Android

$
0
0

I'm working with Xamarin Studio 6.1.3 and trying the latest Xamarin Android Support Design library 25.3.1, my target is set to API 24 and min version is 19.

I have a CoordinateLayout with several layouts inside, and I want to display two FABs anchored between two layouts, incidentInfoView and bottom_layout, but I can't the FABs to get in between the two layouts, instead they're rendered as if no layout_anchor nor layout_anchorGravity attributes were set, if I use layout_gravity I can position the FABs around my layout but I wish to display them in between the two layouts.

Only when I put the app in the background or trigger a onResume method call that the FABs are rendered accordingly, but that doesn't happen all the time, sometimes even if do this the buttons stay the same.

Another problem I have is that I'm unable to use the BackgroundTintList property, when I try to change the color of it I get an exception thrown:

    Java.Lang.NoSuchMethodError: no method with name='setBackgroundTintList' signature='(Landroid/content/res/ColorStateList;)V' in class Landroid/view/View;
      at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
      at Java.Interop.JniEnvironment+InstanceMethods.GetMethodID (Java.Interop.JniObjectReference type, System.String name, System.String signature) [0x00068] in /Users/builder/data/lanes/3511/501e63ce/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:11240
      at Java.Interop.JniType.GetInstanceMethod (System.String name, System.String signature) [0x0000f] in /Users/builder/data/lanes/3511/501e63ce/source/Java.Interop/src/Java.Interop/Java.Interop/JniType.cs:228
      at Java.Interop.JniPeerMembers+JniInstanceMethods.GetMethodInfo (System.String encodedMember) [0x0003a] in /Users/builder/data/lanes/3511/501e63ce/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods.cs:94
      at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00023] in /Users/builder/data/lanes/3511/501e63ce/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:25
      at Android.Views.View.set_BackgroundTintList (Android.Content.Res.ColorStateList value) [0x0002c] in /Users/builder/data/lanes/3511/501e63ce/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Android.Views.View.cs:4324
      at QAbogados.Droid.Activities.AssigmentsActivity.SetAssignedStatus () [0x00033] in /Users/enapsys/Documents/QAbogados/git/QAbogados/UI/Droid/Activities/AssigmentsActivity.cs:315
      at QAbogados.Droid.Presenters.AssignmentPresenter.SetCurrentAssignmentLifecycle (System.String currentLifecycle) [0x00024] in /Users/enapsys/Documents/QAbogados/git/QAbogados/UI/Droid/Presenters/AssignmentPresenter.cs:70
      at QAbogados.Droid.Presenters.AssignmentPresenter+<GetAssignment>c__AnonStorey0.<>m__0 () [0x00028] in /Users/enapsys/Documents/QAbogados/git/QAbogados/UI/Droid/Presenters/AssignmentPresenter.cs:47
      at Java.Lang.Thread+RunnableImplementor.Run () [0x0000b] in /Users/builder/data/lanes/3511/501e63ce/source/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36
      at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in /Users/builder/data/lanes/3511/501e63ce/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Java.Lang.IRunnable.cs:81
      at at (wrapper dynamic-method) System.Object:23606372-f802-4ea0-9ffb-87fd4c126367 (intptr,intptr)
      at java.lang.NoSuchMethodError: no method with name='setBackgroundTintList' signature='(Landroid/content/res/ColorStateList;)V' in class Landroid/view/View;
      at at mono.java.lang.RunnableImplementor.n_run(Native Method)
      at at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
      at at android.os.Handler.handleCallback(Handler.java:733)
      at at android.os.Handler.dispatchMessage(Handler.java:95)
      at at android.os.Looper.loop(Looper.java:136)
      at at android.app.ActivityThread.main(ActivityThread.java:5057)
      at at java.lang.reflect.Method.invokeNative(Native Method)
      at at java.lang.reflect.Method.invoke(Method.java:515)
      at at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
      at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
      at at dalvik.system.NativeStart.main(Native Method)

The way I'm trying to change the BackgroundTintList is like this:

fab.BackgroundTintList = GetInProgressColor();

Is there anyway to deal with the first problem? I tried to set the Visibility to Gone in the OnCreate method and then changing it to Visible, but it didn't force the FABs to anchor where they should.

On the other problem, why is BackgroundTintList not being recognized?


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>