Status Update
Comments
[Deleted User] <[Deleted User]> #3
Workaround: wrap your View in a CoordinatorLayout
re...@gmail.com <re...@gmail.com> #4
Yes. Got the same issue over here
re...@gmail.com <re...@gmail.com> #5
wrapping it into the coordinator layout worked. Thanks a lot Joe!
ch...@gmail.com <ch...@gmail.com> #6
Wrapping inside a CoordinatorLayout is a pretty crummy solution. Is there any possibility of a point update that fixes this?
ar...@idealo.de <ar...@idealo.de> #7
Same problem here. Our FAB is already residing directly inside a CoordinatorLayout among other children.
08-19 17:30:29.892 26080 26080 E AndroidRuntime: java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to android.support.design.widget.CoordinatorLayout$LayoutParams
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.support.design.widget.FloatingActionButton$Behavior.isBottomSheet(FloatingActionButton.java:597)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.support.design.widget.FloatingActionButton$Behavior.onDependentViewChanged(FloatingActionButton.java:589)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.support.design.widget.FloatingActionButton$Behavior.onDependentViewChanged(FloatingActionButton.java:528)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.support.design.widget.CoordinatorLayout.offsetChildToAnchor(CoordinatorLayout.java:1564)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.support.design.widget.CoordinatorLayout.onChildViewsChanged(CoordinatorLayout.java:1233)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.support.design.widget.CoordinatorLayout$OnPreDrawListener.onPreDraw(CoordinatorLayout.java:1812)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:944)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2201)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1246)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6301)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:871)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.view.Choreographer.doCallbacks(Choreographer.java:683)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.view.Choreographer.doFrame(Choreographer.java:619)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:751)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.os.Looper.loop(Looper.java:154)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6077)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to android.support.design.widget.CoordinatorLayout$LayoutParams
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.support.design.widget.FloatingActionButton$Behavior.isBottomSheet(FloatingActionButton.java:597)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.support.design.widget.FloatingActionButton$Behavior.onDependentViewChanged(FloatingActionButton.java:589)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.support.design.widget.FloatingActionButton$Behavior.onDependentViewChanged(FloatingActionButton.java:528)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.support.design.widget.CoordinatorLayout.offsetChildToAnchor(CoordinatorLayout.java:1564)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.support.design.widget.CoordinatorLayout.onChildViewsChanged(CoordinatorLayout.java:1233)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.support.design.widget.CoordinatorLayout$OnPreDrawListener.onPreDraw(CoordinatorLayout.java:1812)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:944)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2201)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1246)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6301)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:871)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.view.Choreographer.doCallbacks(Choreographer.java:683)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.view.Choreographer.doFrame(Choreographer.java:619)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:751)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.os.Looper.loop(Looper.java:154)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6077)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
08-19 17:30:29.892 26080 26080 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
ju...@gmail.com <ju...@gmail.com> #8
same error.... i hope in a solution
ro...@gmail.com <ro...@gmail.com> #9
Same problem here and wrapping with a plain CoordinatorLayout with only weight and height worked for me too.
re...@gmail.com <re...@gmail.com> #10
Does sdk23 work? We all on sdk24 imo.
al...@android.com <al...@android.com>
ju...@gmail.com <ju...@gmail.com> #11
the solution for me:
the anchor value want only direct child of coordinatorlayout
<CoordinatorLayout>
<LinearLayout
id=direct child>
<LinearLayout
id= no direct child>
<View>
</LinearLayout>
<LinearLayout>
<Fab
anchor= id = direct child>
</CoordinatorLayout>
sorry for my english, this work for me
the anchor value want only direct child of coordinatorlayout
<CoordinatorLayout>
<LinearLayout
id=direct child>
<LinearLayout
id= no direct child>
<View>
</LinearLayout>
<LinearLayout>
<Fab
anchor= id = direct child>
</CoordinatorLayout>
sorry for my english, this work for me
ju...@gmail.com <ju...@gmail.com> #12
[Comment deleted]
ch...@google.com <ch...@google.com>
yh...@gmail.com <yh...@gmail.com> #14
Same issue here, I successfully stopped the crashes by changing the anchor on the FAB, I was not targeting the main parent layout at first.
pa...@gmail.com <pa...@gmail.com> #15
Same issue here, I had my FAB anchored to a CardView
th...@gmail.com <th...@gmail.com> #16
Same issue. Happening since I updated my SDK 24. Still no help. It's a bug from Google side because it has been working since past 10 months.
th...@gmail.com <th...@gmail.com> #17
Found a solution.
My earlier XML looked like this:
<CoordinatorLayout>
<LinearLayout
id=direct child>
<ImageView
id = no_direct_child> //fab anchor
<LinearLayout
id= no direct child>
<View>
</LinearLayout>
<LinearLayout>
<Fab
anchor= id = direct child>
</CoordinatorLayout>
New XML:
<CoordinatorLayout>
<ImageView
id = direct_child> //fab anchor
<LinearLayout
id=direct child>
<LinearLayout
id= no direct child>
<View>
</LinearLayout>
<LinearLayout>
<Fab
anchor= id = direct child>
</CoordinatorLayout>
Hope this helps.
My earlier XML looked like this:
<CoordinatorLayout>
<LinearLayout
id=direct child>
<ImageView
id = no_direct_child> //fab anchor
<LinearLayout
id= no direct child>
<View>
</LinearLayout>
<LinearLayout>
<Fab
anchor= id = direct child>
</CoordinatorLayout>
New XML:
<CoordinatorLayout>
<ImageView
id = direct_child> //fab anchor
<LinearLayout
id=direct child>
<LinearLayout
id= no direct child>
<View>
</LinearLayout>
<LinearLayout>
<Fab
anchor= id = direct child>
</CoordinatorLayout>
Hope this helps.
ja...@gmail.com <ja...@gmail.com> #18
Totally agree with #17, today I've updated my SDK to 24 and the issue has started. With version 23 everything works fine.
Any solution?
Any solution?
mr...@gmail.com <mr...@gmail.com> #19
Same here. 23.2.0 was working fine.
li...@gmail.com <li...@gmail.com> #24
Same issue, any solution ?
ro...@gmail.com <ro...@gmail.com> #25
As said in #2, wrap your anchor object in <CoordinatorLayout> and add the layout_width/height attributes as appropiate and nothing more.
This works for me.
This seems like a simple ClassCastException while using the CoordinatorLayout.ParamLayout as if they were ViewGroup.ParamLayout.
This works for me.
This seems like a simple ClassCastException while using the CoordinatorLayout.ParamLayout as if they were ViewGroup.ParamLayout.
pr...@gmail.com <pr...@gmail.com> #26
ok give some example or blog if the issue is resolved
ro...@gmail.com <ro...@gmail.com> #27
Ok.
My initial, throwing exceptions, xml layout was like this:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android "
xmlns:app="http://schemas.android.com/apk/res-auto "
android:id="@+id/topView"
style="@style/TopFragment"
android:fillViewport="true">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v7.widget.RecyclerView
android:id="@+id/itemsRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:cacheColorHint="@android:color/transparent"
android:requiresFadingEdge="none"
android:scrollbars="vertical" />
</android.support.v4.widget.SwipeRefreshLayout>
<android.support.constraint.ConstraintLayout
android:id="@+id/fabContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="@+id/topView"
app:layout_constraintRight_toRightOf="@+id/topView">
<android.support.design.widget.FloatingActionButton
android:id="@+id/giveFloatButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
style="@style/FloatingActionButton"
android:clickable="true"
app:fabSize="normal"
app:layout_constraintBottom_toBottomOf="@+id/fabContainer"
app:layout_constraintRight_toRightOf="@+id/fabContainer" />
<!--- the rest of my layout --->
</android.support.constraint.ConstraintLayout>
<!--- the rest of my layout --->
</android.support.design.widget.CoordinatorLayout>
Now, after wrapping, it looks like:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android "
xmlns:app="http://schemas.android.com/apk/res-auto "
android:id="@+id/topView"
style="@style/TopFragment"
android:fillViewport="true">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="@+id/itemsRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:cacheColorHint="@android:color/transparent"
android:requiresFadingEdge="none"
android:scrollbars="vertical" />
</android.support.design.widget.CoordinatorLayout>
</android.support.v4.widget.SwipeRefreshLayout>
<android.support.constraint.ConstraintLayout
android:id="@+id/fabContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="@+id/topView"
app:layout_constraintRight_toRightOf="@+id/topView">
<android.support.design.widget.FloatingActionButton
android:id="@+id/giveFloatButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
style="@style/FloatingActionButton"
android:clickable="true"
app:fabSize="normal"
app:layout_constraintBottom_toBottomOf="@+id/fabContainer"
app:layout_constraintRight_toRightOf="@+id/fabContainer" />
<!--- the rest of my layout --->
</android.support.constraint.ConstraintLayout>
<!--- the rest of my layout --->
</android.support.design.widget.CoordinatorLayout>
Hope it helps
My initial, throwing exceptions, xml layout was like this:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="
xmlns:app="
android:id="@+id/topView"
style="@style/TopFragment"
android:fillViewport="true">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v7.widget.RecyclerView
android:id="@+id/itemsRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:cacheColorHint="@android:color/transparent"
android:requiresFadingEdge="none"
android:scrollbars="vertical" />
</android.support.v4.widget.SwipeRefreshLayout>
<android.support.constraint.ConstraintLayout
android:id="@+id/fabContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="@+id/topView"
app:layout_constraintRight_toRightOf="@+id/topView">
<android.support.design.widget.FloatingActionButton
android:id="@+id/giveFloatButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
style="@style/FloatingActionButton"
android:clickable="true"
app:fabSize="normal"
app:layout_constraintBottom_toBottomOf="@+id/fabContainer"
app:layout_constraintRight_toRightOf="@+id/fabContainer" />
<!--- the rest of my layout --->
</android.support.constraint.ConstraintLayout>
<!--- the rest of my layout --->
</android.support.design.widget.CoordinatorLayout>
Now, after wrapping, it looks like:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="
xmlns:app="
android:id="@+id/topView"
style="@style/TopFragment"
android:fillViewport="true">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="@+id/itemsRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:cacheColorHint="@android:color/transparent"
android:requiresFadingEdge="none"
android:scrollbars="vertical" />
</android.support.design.widget.CoordinatorLayout>
</android.support.v4.widget.SwipeRefreshLayout>
<android.support.constraint.ConstraintLayout
android:id="@+id/fabContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="@+id/topView"
app:layout_constraintRight_toRightOf="@+id/topView">
<android.support.design.widget.FloatingActionButton
android:id="@+id/giveFloatButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
style="@style/FloatingActionButton"
android:clickable="true"
app:fabSize="normal"
app:layout_constraintBottom_toBottomOf="@+id/fabContainer"
app:layout_constraintRight_toRightOf="@+id/fabContainer" />
<!--- the rest of my layout --->
</android.support.constraint.ConstraintLayout>
<!--- the rest of my layout --->
</android.support.design.widget.CoordinatorLayout>
Hope it helps
ml...@gmail.com <ml...@gmail.com> #28
How can I see changes in source code between 24.2.0 and 24.2.1?
I clonedhttps://android.googlesource.com/platform/frameworks/support but latest commit is dated by July 1 and there are no tags that looks like Android Support Library versions.
I also created SO questionhttp://stackoverflow.com/q/39271969/746347 .
I cloned
I also created SO question
[Deleted User] <[Deleted User]> #30
I can confirm this has been fixed with the recent release of 24.2.1
ch...@google.com <ch...@google.com> #31
Fixed in the 24.2.1 of the support library
hy...@gmail.com <hy...@gmail.com> #32
I have same issue in support libraries 24.2.1 and 25.0.1.
FAB shows fine only when anchor set to direct child of coordinator layout.
FAB shows fine only when anchor set to direct child of coordinator layout.
hy...@gmail.com <hy...@gmail.com> #33
Issue is happened only on first inflate UI, after that behaviour and gravity of FAB is OK.
di...@gmail.com <di...@gmail.com> #34
da...@googlemail.com <da...@googlemail.com> #35
Got the same issue since upgrade from support libraries 23.1.1 up to 25.0.1.
Seems like #35 is my current working, preferred solution.
Often my FAB was displayed at the top left cornor instead bottom right on it's anchor (like described inhttp://stackoverflow.com/a/40935790/2358687 ). I simply have a CoordninatorLayout with a RecyclerView and the FAB within.
Initially I wanted to align the FAB via anchor definition in XML:
app:layout_anchor="@id/recyclerView"
app:layout_anchorGravity="bottom|end"
I replaced the app:layout_anchor* attributes by
android:layout_gravity="bottom|end"
Thanks dingenen!
Seems like #35 is my current working, preferred solution.
Often my FAB was displayed at the top left cornor instead bottom right on it's anchor (like described in
Initially I wanted to align the FAB via anchor definition in XML:
app:layout_anchor="@id/recyclerView"
app:layout_anchorGravity="bottom|end"
I replaced the app:layout_anchor* attributes by
android:layout_gravity="bottom|end"
Thanks dingenen!
pe...@gmail.com <pe...@gmail.com> #36
I am having the same issue with #34.
I have a recyclerview list item containing a FAB that is anchored to an imageView all in a CardView. On view inflation some of the FAB doesn't seem to anchor to the view. But after scrolling down and up, the fab corrects its position.
I have a recyclerview list item containing a FAB that is anchored to an imageView all in a CardView. On view inflation some of the FAB doesn't seem to anchor to the view. But after scrolling down and up, the fab corrects its position.
Description
Version used: 24.2.0
Theme used: Theme.AppCompat.Light.DarkActionBar
Devices/Android versions reproduced on: Android 6.0 Emulator
Prior to support library version 24.2.0, a FAB could be anchored to a nested child of a CoordinatorLayout.
For example, with the following view hierarchy:
<CoordinatorLayout>
<LinearLayout>
<LinearLayout>
<View>
</LinearLayout>
<LinearLayout>
<Fab>
</CoordinatorLayout>
The FAB could be anchored to View.
With 24.2.0, the app now crashes with the exception:
android.widget.LinearLayout$LayoutParams cannot be cast to android.support.design.widget.CoordinatorLayout$LayoutParams
This is due to the isBottomSheet() method in the FloatingActionButton class. It assumes that the view has CoordinatorLayout LayoutParams.
Attached is a project demonstrating this issue. The example works if the compiled support library version is changed to 24.0.0.