小吃店和其他动画在某些Android设备上停止工作 [英] Snackbar and other animations stopped working on some Android devices

查看:53
本文介绍了小吃店和其他动画在某些Android设备上停止工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常奇怪的问题,我无法弄清楚.直到最近我才成为问题,但我似乎无法退缩以防止出现这种情况.另外一个奇怪的事情是,它可以在某些设备上运行,而在其他设备上则不能.

I have a very odd issue that I cannot figure out. I was not an issue until recently but I can't seem to revert back to prevent it. Also the other odd thing is it works on some devices and others it does not.

问题是动画.特别是小吃店.快餐栏应该上下动画,但不是.它只显示然后隐藏.请查看下面的视频以查看问题.

The issue is animations. One in particular is snack bar. The snackbar should animate up and down but it is not. it just shows then hides. check video below to see issue.

发布视频

这是用于在其中设置小吃栏动画的Android代码

Here is the Android code to animate the snackbar in

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.

Its using ViewCompat for the v4 Library. I have other animations working in another activity working fine. Also the issue is not on just one activity its all of them. That makes me think its system wide somehow. But they all use different internal themes but all extend 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>

可运行的设备

  • Nexus 9(棉花糖)
  • Nexus 4(KitKat)
  • Galaxy S7(棉花糖)

设备不起作用

  • Droid Turbo 2(棉花糖)
  • Galaxy S7(棉花糖)*我的设备可以使用,我的测试仪不能使用
  • Nexus 6p(Android N)

其他动画问题与开关有关.我有2个布局相同,切换时结结巴结,而另一个则没有动画切换.

The other animation issues are with Switches. I have 2 in same layout and one stutters when switched and the other just switches with no animation.

我还为我的AppBarLayout设置了一个LayoutTransition来对我的TabLayout的隐藏/显示进行动画处理,并且在所有设备上都能正常工作

I also have a LayoutTransition set to my AppBarLayout to animation the hiding/showing of my TabLayout and it works fine and all devices

推荐答案

我找到了发生这种情况的原因,但还没有找到解决方法.

I found the reason why this is happening, but not how to fix yet.

/**
 * Returns true if we should animate the Snackbar view in/out.
 */
private boolean shouldAnimate() {
    return !mAccessibilityManager.isEnabled();
}

这由Snackbar类调用,在正常运行的设备上为false,在不正常运行的设备上为true.有人知道吗?

That is called by Snackbar class and is false on working devices, and true on devices not working. Does anyone know about this?

因此,在我的系统设置中禁用了lastpass之后,小吃栏现在会按需设置动画.那是如何工作的,这很疯狂. Nova启动器具有相同的影响.我猜想任何启用了辅助功能的服务都将导致快餐栏动画无法正常工作.

So after i disabled lastpass in my system settings, accessibility the snackbar now animates as it should. That is crazy how that works. Nova launcher has the same affect. I guess any service in accessibility that is enabled will cause the snackbar animation to not work.

这篇关于小吃店和其他动画在某些Android设备上停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆