IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 移动开发 -> Android animate scaleX() 失效 -> 正文阅读

[移动开发]Android animate scaleX() 失效

? ?最近遇到很奇怪的问题。发现View.animate().scaleX()失效的。

? 如代码如下:

? ?

frameworks/base/packages/SystemUI/src/com/android/systemui/qs/customize/TileAdapter.java
          public void stopDrag() {
               itemView.animate()
                       .setDuration(DRAG_LENGTH)
                       .scaleX(1)
                       .scaleY(1);
               mTileView.findViewById(R.id.tile_label).animate()
                       .setDuration(DRAG_LENGTH)
                       .alpha(1);
               mTileView.getAppLabel().animate()
                       .setDuration(DRAG_LENGTH)
                       .alpha(.6f);
           }

? ? 发现在调用 itemView.animate().setDuration(DRAG_LENGTH).scaleX(1).scaleY(1); 不起作用。导致的问题是?:当之前调用itemView.animate() 的行为无法恢复。

如 所报的bug :

[SystemUI][100%]前提:语言为西班牙语。下拉状态栏,点击编辑,长按storage或者Focus mode时,字体重叠(具体见视频)。

步骤:前提:语言为西班牙语

1、下拉状态栏,点击编辑,长按storage或者Focus mode

问题点:字体重叠
期望结果:字体不会重叠

分析:

针对此问题,尝试添加log,进行跟踪.

      itemView.animate()
      .setDuration(DRAG_LENGTH)
      .scaleX(1)
      .scaleY(1).setListener(new Animator.AnimatorListener(){
                           public void onAnimationStart(Animator animation){
                               Log.e("XIBIN", "TileAdapter ::stopDrag onAnimationStart");
                                   }
                           public void onAnimationEnd(Animator animation){
                               Log.e("XIBIN", "TileAdapter ::stopDrag onAnimationEnd",new RuntimeException());
                           }
                           public  void onAnimationCancel(Animator animation){
                               Log.e("XIBIN", "TileAdapter ::stopDrag onAnimationCancel",new RuntimeException());
                           }
                           public void onAnimationRepeat(Animator animation){
                               Log.e("XIBIN", "TileAdapter ::stopDrag onAnimationRepeat");
                           }
                    });

通过打印log ,发现有 onAnimationCancel 字样的关键字输出,并存在打印堆栈

08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : TileAdapter ::stopDrag onAnimationCancel
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : java.lang.RuntimeException
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at com.android.systemui.qs.customize.TileAdapter$Holder$1.onAnimationCancel(TileAdapter.java:520)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.view.ViewPropertyAnimator$AnimatorEventListener.onAnimationCancel(ViewPropertyAnimator.java:1086)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.animation.ValueAnimator.cancel(ValueAnimator.java:1132)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.view.ViewPropertyAnimator.cancel(ViewPropertyAnimator.java:424)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at androidx.recyclerview.widget.DefaultItemAnimator.endAnimation(DefaultItemAnimator.java:439)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at androidx.recyclerview.widget.DefaultItemAnimator.resetAnimation(DefaultItemAnimator.java:526)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at androidx.recyclerview.widget.DefaultItemAnimator.animateMove(DefaultItemAnimator.java:260)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at androidx.recyclerview.widget.SimpleItemAnimator.animatePersistence(SimpleItemAnimator.java:138)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at androidx.recyclerview.widget.RecyclerView$4.processPersistent(RecyclerView.java:643)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at androidx.recyclerview.widget.ViewInfoStore.process(ViewInfoStore.java:239)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep3(RecyclerView.java:4299)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3952)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4499)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.view.View.layout(View.java:23005)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.view.ViewGroup.layout(ViewGroup.java:6453)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.view.View.layout(View.java:23005)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.view.ViewGroup.layout(ViewGroup.java:6453)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.view.View.layout(View.java:23005)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.view.ViewGroup.layout(ViewGroup.java:6453)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at com.android.systemui.qs.QSContainerImpl.onLayout(QSContainerImpl.java:193)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.view.View.layout(View.java:23005)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.view.ViewGroup.layout(ViewGroup.java:6453)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.view.View.layout(View.java:23005)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.view.ViewGroup.layout(ViewGroup.java:6453)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.view.View.layout(View.java:23005)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.view.ViewGroup.layout(ViewGroup.java:6453)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.view.View.layout(View.java:23005)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.view.ViewGroup.layout(ViewGroup.java:6453)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.view.View.layout(View.java:23005)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.view.ViewGroup.layout(ViewGroup.java:6453)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:3580)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3038)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2020)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8410)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.view.Choreographer$CallbackRecord.run(Choreographer.java:974)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.view.Choreographer.doCallbacks(Choreographer.java:797)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.view.Choreographer.doFrame(Choreographer.java:732)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:959)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.os.Handler.handleCallback(Handler.java:938)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.os.Handler.dispatchMessage(Handler.java:99)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.os.Looper.loop(Looper.java:230)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at android.app.ActivityThread.main(ActivityThread.java:7700)
08-11 17:03:51.874 ?1175 ?1175 E XIBIN ? : ?? ?at java.lang.reflect.Method.invoke(Native Method)
08-11 17:03:51.875 ?1175 ?1175 E XIBIN ? : ?? ?at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612)
08-11 17:03:51.875 ?1175 ?1175 E XIBIN ? : ?? ?at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:997)

发现在执行?onLayout() ,排列布局时,将动画cancel了。 知道此原因之后,可以延后执行,使用postDelayed 延后100毫秒。测试正常。

总结:

? ? ? ?遇到类似的问题,多查看源码并在关键之后添加log进行分析。

  移动开发 最新文章
Vue3装载axios和element-ui
android adb cmd
【xcode】Xcode常用快捷键与技巧
Android开发中的线程池使用
Java 和 Android 的 Base64
Android 测试文字编码格式
微信小程序支付
安卓权限记录
知乎之自动养号
【Android Jetpack】DataStore
上一篇文章      下一篇文章      查看所有文章
加:2021-08-12 16:42:49  更:2021-08-12 16:43:31 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年5日历 -2024/5/19 6:03:15-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码