动作条显示动作的动画
Animation for action bar show action
我正在使用 android 4.2 和最新版本的 appCompat。我已经使用这些方法实现了显示和隐藏我的操作栏:
final ActionBar actionBar = getSupportActionBar();
actionBar.hide();
actionBar.show();
当操作栏被隐藏时,它会以流畅的动画逐渐向上滑动。但是,当我显示它时,它几乎立即出现在屏幕上,几乎没有流畅的动画滑落。有什么方法可以将它配置为像隐藏它时一样流畅地显示吗?
尝试启用默认情况下未启用的操作栏 hide/shown 动画,因此请使用以下代码启用 hide/shown 动画:
actionBar.setShowHideAnimationEnabled(boolean enabled);
在 AppBarLayout
中设置布局 android:animateLayoutChanges="true"
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay"
android:animateLayoutChanges="true">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"
/>
</android.support.design.widget.AppBarLayout>
以及隐藏或显示工具栏 (ActionBar) 的切换
if (getSupportActionBar() != null) {
if (getSupportActionBar().isShowing()) {
getSupportActionBar().hide();
} else {
getSupportActionBar().show();
}
}
我正在使用 android 4.2 和最新版本的 appCompat。我已经使用这些方法实现了显示和隐藏我的操作栏:
final ActionBar actionBar = getSupportActionBar();
actionBar.hide();
actionBar.show();
当操作栏被隐藏时,它会以流畅的动画逐渐向上滑动。但是,当我显示它时,它几乎立即出现在屏幕上,几乎没有流畅的动画滑落。有什么方法可以将它配置为像隐藏它时一样流畅地显示吗?
尝试启用默认情况下未启用的操作栏 hide/shown 动画,因此请使用以下代码启用 hide/shown 动画:
actionBar.setShowHideAnimationEnabled(boolean enabled);
在 AppBarLayout
android:animateLayoutChanges="true"
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay"
android:animateLayoutChanges="true">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"
/>
</android.support.design.widget.AppBarLayout>
以及隐藏或显示工具栏 (ActionBar) 的切换
if (getSupportActionBar() != null) {
if (getSupportActionBar().isShowing()) {
getSupportActionBar().hide();
} else {
getSupportActionBar().show();
}
}