Shijil Shijil - 1 year ago 129
Android Question

ClassCastException in FloatingActionButton

got ClassCastException in after updating lib to 24.2.0. its working fine in lib version 24.1.1

java.lang.ClassCastException: android.widget.FrameLayout$LayoutParams cannot be cast to$LayoutParams
at android.view.ViewTreeObserver.dispatchOnPreDraw(
at android.view.ViewRootImpl.performTraversals(
at android.view.ViewRootImpl.doTraversal(
at android.view.ViewRootImpl$
at android.view.Choreographer$
at android.view.Choreographer.doCallbacks(
at android.view.Choreographer.doFrame(
at android.view.Choreographer$
at android.os.Handler.handleCallback(
at android.os.Handler.dispatchMessage(
at android.os.Looper.loop(

sJy sJy
Answer Source

The issue seems to be latest Support Library version 24.2.0. Setting the anchor for FloatingButton to a view which is not a direct child of its parent CoordinatorLayout is causing this.

This is a known issue as per Android Open Source Project - Issue Tracker. You can see the issue marked as future release for 24.2.1 at FAB can no longer be anchored to indirect children of CoordinatorLayout.

Possible workaround from the comments in that reported issue are

  • Set the anchor view of FloatingActionButton to direct child of Coordinatorlayout.


  • Wrap the View which you are setting as the anchor for FloatinActionButton inside a new CoordinatorLayout

From Android Open Source Project - Issue Tracker

Status: FutureRelease

Labels: Target-Support-24.2.1

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download