支持库24.2.1中锚定的FloatingActionButton的错误 [英] Bug with anchored FloatingActionButton in support library 24.2.1
本文介绍了支持库24.2.1中锚定的FloatingActionButton的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
自24.2.0起,我一直遇到这个问题,但是现在我使用的是24.2.1,该错误仍然存在,它只能正常工作< = 24.1.1.
I have been having this issue since 24.2.0, but now I'm using 24.2.1 and the bug is still here, it only works well <= 24.1.1.
我有一个这样的锚定FloatingActionButton:
I have an anchored FloatingActionButton done like this:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/contact_coordinator_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context="es.cocode.baseapp.contact.ContactFragment">
<FrameLayout
android:id="@+id/map_fragment_container"
android:layout_width="match_parent"
android:layout_height="198dp"
android:layout_marginBottom="210dp">
<fragment
android:id="@+id/map_fragment"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_fullscreen_map"
android:src="@drawable/ic_fullscreen_white_48dp"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_margin="@dimen/fab_margin"
app:layout_anchor="@id/map_fragment_container"
app:layout_anchorGravity="bottom|end" />
</android.support.design.widget.CoordinatorLayout>
</ScrollView>
它通常是这样的:
但是有时会出现错误,并且锚点不起作用:
But sometimes the bug appears and the anchor doesn't work:
是否有解决此问题的方法,还是应该等到此错误得到修复并改用24.1.1为止?
Is there a way to solve this, or should I wait until this bug gets fixed and use 24.1.1 instead?
推荐答案
解决方案是在XML中将FloatingActionButton
可见性设置为GONE
,并在准备好映射后将其重新设置为VISIBLE
.>
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);
}
编辑:这是此 查看全文