android - 支持库 24.2.1 中锚定 FloatingActionButton 的错误

标签 android android-support-library android-design-library androiddesignsupport floating-action-button

我从 24.2.0 开始就遇到这个问题,但现在我使用的是 24.2.1 并且错误仍然存​​在,它只能很好地工作 <= 24.1.1。

我有一个固定的 FloatingActionButton 是这样完成的:

<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>

它通常是这样工作的:

FAB working well

但有时会出现错误, anchor 不起作用:

FAB not working

有没有办法解决这个问题,还是我应该等到这个错误得到修复,然后改用 24.1.1?

最佳答案

至于 5/2/2017 (25.3.1),该错误仍未修复。在尝试了所有解决方案之后,唯一对我有用的是:

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

yourView 是锚定 View 。

关于android - 支持库 24.2.1 中锚定 FloatingActionButton 的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39600012/

相关文章:

android - Android源码构建#ifdefs在编译中是如何工作的

android - 在 Android API < 21 中使用 setImageTintMode

android - 使用 AndroidX 时找不到辅助 dex 文件中的 MultiDexApplication 类

android - TextInputLayout 密码圆角切换

android - CollapsingToolbarLayout 无法正常工作

安卓应用 : Storing lots of images on a server

Android 谷歌地图错误,无法启动 Activity ComponentInfo

android - Travis CI Android - 找不到匹配的版本

android - 自定义 NavigationView - 添加动态 headerView,Android 支持设计库

java - 第二种布局按钮不起作用