Bug with anchored FloatingActionButton in support library 24.2.1

吃可爱长大的小学妹 提交于 2019-12-04 00:56:09

As for 5/2/2017 (25.3.1) the bug still hasn't been fixed. After trying all solutions, the only one that worked for me was:

yourView.post(new Runnable() { 
    @Override 
    public void run() { 
        yourView.requestLayout(); 
    } 
}); 

Where yourView is the anchored view.

The solution was to set the FloatingActionButton visibility to GONE in the XML and when the map is ready set it back to VISIBLE.

@Override
public void onMapReady(GoogleMap googleMap) {
    . . .
    yourFAB.setVisibility(View.VISIBLE);
}

EDIT: This is a workaround for this bug.

Marked as Fixed Issue is fixed and released in 26.0.0 version of support library.

Bug reported and hopefully fixed soon. Please star it.

Well my friend there is another way to it using latest support libraries and not using any other thing .

Just use this -

<android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_margin="@dimen/activity_horizontal_margin"
        android:src="@drawable/ic_add"
        android:layout_gravity="center_vertical|center_horizontal"
        app:layout_anchor="@+id/appBar"
        app:layout_anchorGravity="bottom|right" />
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!