水平android:animateLayoutChanges =“true”动画不流畅

水平android:animateLayoutChanges =“true”动画不流畅,第1张

概述我有一个动画如下的布局 txt_billion是动态显示的,android:animateLayoutChanges =“true”(下面的布局代码). 请注意,百人正在跳跃(实际上所有人都在跳跃,但是百人才更加明显).如何防止文字跳跃? <LinearLayout android:layout_width="match_parent" android:layout_height= 我有一个动画如下的布局

txt_billion是动态显示的,androID:animateLayoutChanges =“true”(下面的布局代码).

请注意,百人正在跳跃(实际上所有人都在跳跃,但是百人才更加明显).如何防止文字跳跃?

<linearLayout    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content"    androID:animateLayoutChanges="true"    androID:orIEntation="horizontal">    <TextVIEw        androID:layout_wIDth="0dp"        androID:layout_height="wrap_content"        androID:layout_weight="1"        androID:gravity="center"        androID:padding="8dp"        androID:background="#9f9"        androID:text="Hundreds" />    <TextVIEw        androID:layout_wIDth="0dp"        androID:layout_height="wrap_content"        androID:layout_weight="1"        androID:gravity="center"        androID:padding="8dp"        androID:background="#f9f"        androID:text="Thousands" />    <TextVIEw        androID:layout_wIDth="0dp"        androID:layout_height="wrap_content"        androID:layout_weight="1"        androID:gravity="center"        androID:padding="8dp"        androID:background="#0ff"        androID:text="Millions" />    <TextVIEw        androID:ID="@+ID/txt_billion"        androID:layout_wIDth="0dp"        androID:layout_height="wrap_content"        androID:layout_weight="1"        androID:gravity="center"        androID:padding="8dp"        androID:visibility="gone"        androID:background="#ff0"        androID:text="Billions" /></linearLayout>

您可以从https://github.com/elye/issue_horizontal_layout_animate获取代码进行测试

解决方法 尝试使用支持转换而不是animateLayoutChanges

首先,从XML文件中删除androID:animateLayoutChanges =“true”

之后,将编译’com.androID.support:Transition:25.4.0’添加到您的应用依赖项中.

然后,在更改可见性之前添加此行(来自androID.support.Transition包的TransitionManager)

TransitionManager.beginDelayedTransition(parentOfAnimatedVIEw);

为了你的代码

public voID clickMe(VIEw vIEw) {        TransitionManager.beginDelayedTransition((VIEwGroup) billionText.getParent());        if (billionText.getVisibility() == VIEw.GONE) {            billionText.setVisibility(VIEw.VISIBLE);        } else {            billionText.setVisibility(VIEw.GONE);        }    }
总结

以上是内存溢出为你收集整理的水平android:animateLayoutChanges =“true”动画不流畅全部内容,希望文章能够帮你解决水平android:animateLayoutChanges =“true”动画不流畅所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1126053.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)

    保存