【发布时间】:2016-07-29 13:39:42
【问题描述】:
我有一个支持FloatingActionButton 的CoordinatorLayout,我想在其中显示一个Snackbar..
<android.support.design.widget.CoordinatorLayout
android:id="@+id/rootView"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
...
</RelativeLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_add_field"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/margin_default"
android:layout_marginBottom="@dimen/profile_floating_margin_bottom"
android:layout_marginRight="@dimen/profile_floating_margin_right"
android:clickable="true"
android:src="@drawable/icon_plus"
app:backgroundTint="@color/brand_green"
app:borderWidth="0dp"
app:elevation="@dimen/fac_icon_elevation"/>
</android.support.design.widget.CoordinatorLayout>
现在我正在展示这样的 Snackbar
Snackbar.make(mRootView, "Something went wrong", Snackbar.LENGHT_SHORT)
.show();
当它显示时,FAB 向上滑动,当它(在 LENGHT_SHORT 之后)消失时,FAB 向下滑动,一切正常。
但是,如果我将 Snackbar 滑开,FAB 会向下移动而没有幻灯片动画。它只是闪烁到它的初始位置。
有趣的是,如果 Snackbar 有两条线(无论它是否有动作)并且被滑开,FAB 会以通常的滑动动画正确地动画回到它的位置。
这是android.support.design.widget.CoordinatorLayout 中的错误吗?
或android.support.design.widget.FloatingActionButton?有什么解决方法吗?
【问题讨论】:
-
你解决了这个问题吗?
标签: android android-coordinatorlayout floating-action-button android-snackbar snackbar