首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Snackbar和其他动画在一些Android设备上停止工作

Snackbar和其他动画在一些Android设备上停止工作
EN

Stack Overflow用户
提问于 2016-05-14 10:40:36
回答 3查看 5.3K关注 0票数 24

我有一个非常奇怪的问题,我不能解决。直到最近,我还不是一个问题,但我似乎不能回到过去来阻止它。另一件奇怪的事情是,它在一些设备上可以工作,而在其他设备上不能。

问题是动画。其中一个特别的是快餐店。快餐栏应该是上下动画的,但它不是。它只是显示,然后隐藏。查看下面的视频以查看问题。

Video of issue

下面是用来为快餐栏添加动画的Android代码

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        ViewCompat.setTranslationY(mView, mView.getHeight());
        ViewCompat.animate(mView)
                .translationY(0f)
                .setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR)
                .setDuration(ANIMATION_DURATION)
                .setListener(new ViewPropertyAnimatorListenerAdapter() {
                    @Override
                    public void onAnimationStart(View view) {
                        mView.animateChildrenIn(ANIMATION_DURATION - ANIMATION_FADE_DURATION,
                                ANIMATION_FADE_DURATION);
                    }

                    @Override
                    public void onAnimationEnd(View view) {
                        onViewShown();
                    }
                }).start();
    }

它使用v4库的ViewCompat。我有其他动画工作在另一个活动正常工作。此外,问题不只是一个活动,而是所有活动。不知何故,这让我认为它的系统范围很广。但它们都使用不同的内部主题,但都扩展了Theme.AppCompat.NoActionBar。

这是我的主要布局

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:elevation="4dp">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:titleTextAppearance="@style/ToolbarTitle"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        app:layout_scrollFlags="scroll|enterAlways|snap"/>

    <android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:tabTextAppearance="@style/TabText"
        app:tabMinWidth="@dimen/tab_minwidth"
        app:tabMode="fixed"
        app:tabGravity="fill"
        app:layout_scrollFlags="enterAlways"/>


</android.support.design.widget.AppBarLayout>

<FrameLayout
    android:id="@+id/content_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" >

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</FrameLayout>

<fr.castorflex.android.circularprogressbar.CircularProgressBar
    android:id="@+id/base_progressSpinner"
    android:layout_gravity="center"
    android:layout_width="48dp"
    android:layout_height="48dp"
    android:indeterminate="true"
    android:visibility="invisible"
    app:cpb_color="@color/spinner"
    app:cpb_rotation_speed="1.0"
    app:cpb_sweep_speed="1.0"
    app:cpb_stroke_width="4dp"
    app:cpb_min_sweep_angle="10"
    app:cpb_max_sweep_angle="300"/>

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab_upload"
    android:visibility="gone"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    app:layout_anchor="@id/content_frame"
    app:layout_anchorGravity="bottom|right|end"
    app:borderWidth="0dp"
    android:src="@drawable/app_fab_upload"
    android:layout_margin="@dimen/big_padding"
    android:clickable="true"
    app:backgroundTint="@color/fab_social"/>

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab_muzei"
    android:visibility="gone"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    app:layout_anchor="@id/content_frame"
    app:layout_anchorGravity="bottom|right|end"
    app:borderWidth="0dp"
    android:src="@drawable/app_fab_muzei"
    android:layout_margin="@dimen/big_padding"
    android:clickable="true"
    app:backgroundTint="@color/fab_social"/>

 </android.support.design.widget.CoordinatorLayout>

  • Nexus9(棉花糖)
  • Nexus4 (KitKat)
  • Galaxy S7 (Marshmallow)

  • 睿频2 (Marshmallow)
  • Galaxy S7 (棉花糖)*我的设备工作正常,测试人员没有
  • Nexus6p(安卓N)

我有两个相同的布局,一个在切换时卡顿,另一个只是切换时没有动画。

我也有一个LayoutTransition设置到我的AppBarLayout动画隐藏/显示我的TabLayout,它工作得很好,所有的设备

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37221914

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档