【发布时间】:2016-07-11 09:57:11
【问题描述】:
我正在 AppBarLayout 中使用 android:animateLayoutChanges="true" 制作我的 TabLayout 动画。但是当我设置 TabLayout.setVisibility(View.GONE) 时,我的片段容器会在几毫秒内立即上升到 ActionBar。然后它返回到 TabLayout 的末尾,并随之上升到 ActionBar。我在下面的 gif 中解释了这一点。
按钮 Theory 和 Practice 出于某种原因在 TabLayout 后面,但是当隐藏 TabLayout 动画启动 FrameContainer 时,我的视图坚持TabLayout 的底部。
我录制了一段视频来演示这种行为。 Dropbox 视频播放器跳过一些帧,动画看起来不错。这就是为什么,要注意这个错误,您可以在计算机上加载视频并以高质量观看 5 秒和 11 秒。 Video
我的 LayoutXML:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<SurfaceView
android:layout_width="0px"
android:layout_height="0px"/>
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:visibility="gone"
app:tabGravity="fill"
app:tabIndicatorColor="@android:color/white"
app:tabMode="fixed"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<!--
This FrameLayout holds my fragments.
-->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/outer_background">
<ProgressBar
android:id="@+id/main_load_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:indeterminate="true"/>
</FrameLayout>
<include
android:id="@+id/left_drawer_full"
layout="@layout/navigation_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"/>
</android.support.v4.widget.DrawerLayout>
</android.support.design.widget.CoordinatorLayout>
此外,我正在使用 23.2.1 支持库。
如何解决这种闪烁和跳跃问题?
【问题讨论】:
标签: android android-fragments android-animation material-design android-appbarlayout