android - 如何在 ANDROID 中为 View.GONE 到 View.VISIBLE 的视图设置动画
问题描述
这是我的布局 xml 的结构:
<RelativeView>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<...>
</ScrollView>
<View
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone" />
</RelativeView>
当我希望视图出现时,我View.VISIBLE
在 java 文件中使用。我这样做是因为我不希望 View 与 ScrollView 重叠。
现在,我想为视图设置动画View.GONE
,View.VISIBLE
使其看起来不错。
我知道动画可以从 Alpha 0 到 1 完成。
但是是否可以从 toView.GONE
动画View.VISIBLE
?
解决方案
添加android:animateLayoutChanges="true"
到您的 xml 文件中,如果您想在您的 java 类中淡出使用,并且如果您想要淡入使用。view.animate().alpha(0.0f);
view.animate().alpha(1.0f);
推荐阅读
- azure-active-directory - 使用具有应用程序权限的 Microsoft Graph API 时,租户没有 SPO 许可证
- python - Beautifulsoup类值提取python
- c# - 当您使用带有约束的通用参数时,C# 是否会生成单独的方法?
- docker - 无法连接到第二个 docker 容器 - 端口错误
- listview - 在应用程序开始时,在颤动中滚动到列表视图的最后一个元素
- python-3.x - 每 x 秒将一个值保存到列表中
- javascript - 为什么 React 项目名称不能包含大写字母?
- doctrine-orm - Doctrine Querybuilder, LEFT JOIN 单向 OneToMany 和 ManyToMany 关系
- python - 使用python从文本文件中提取以5开头的任何4位数字的正则表达式
- c++ - C++ - 抛出错误消息