|
Post by account_disabled on Jan 29, 2024 10:25:19 GMT 1
推特 Facebook 领英 电子邮件 复制链接 在Sprout Social,我们的客户依靠我们帮助他们可靠地管理他们的社交媒体内容。 Sprout 客户使用我们的移动 iOS 和 Android 应用程序,以便他们可以随时随地管理他们的社交媒体。当我们决定更新 Android 消息撰写体验以支持发布附加到推文的多个图像时,我们希望让用户清楚何时附加了多个图像,即使在撰写屏幕上不可见时也是如此。 设计方案:使用动画来表示离屏图像 考虑到我们的设计和移动屏幕的限制,附加图像可能会驻留在屏幕外。虽然这并不理想,但考虑到 Compose 屏幕上支持的功能的密度,这是一个必要的让步。对于图像实际上位于屏幕外的情况,我们决定实现水平“弹跳”动画,以指示图像列表是可滚动的。 实现选择:有很多支持基本动画的机制。有些需要在代码中配置,有些则需要在 xml 中配置。在选择替代方案时,我们决定优先考虑向后兼容性(我们支持 sdk 版本 15+)、实施的简单性和可配置性。 最终,我们决定结合使用O这两者都可以在 Java 代码中进行配置,这最终对开 WhatsApp 数据 发人员更加友好:语法很熟悉,并且动画逻辑可以在代码库的一个位置完全定义。 ObjectAnimator 是 Android 框架提供的一个类,允许修改视图的属性。由于 ObjectAnimator 的默认插值器的移动对于我们的用例来说并不自然,因此我们决定使用 EasingInterpolator,这是一个方便的库,提供了许多不同的插值模型。 示例 弹跳动画代码 私人无效doBounceAnimation(); 动画师.setStartDelay(500); 动画师.setDuration(1500); 动画师.start(); } 幸运的是,处理这种行为的代码非常简洁。在第 1 行中,我们指定了如何对 targetView 进行动画处理。在本例中,我们要修改 targetView 的“translationX”属性,即布局后视图的 x 位置。我们希望从初始位置 0dp 的偏移量到向右 25dp 的偏移量进行动画处理,并最终返回到原始位置 0dp 的偏移量。 在第 2 行中,我们指定了我们想要的插值类型。 我们尝试了不同的插值模型,但最终认为 Ease.ELASTIC_IN_OUT 最适合我们的用例。 Compose 中的 Sprout Social Android 弹跳动画 有关在 Android 中支持属性动画的更多信息,请查看属性动画开发人员文档。 动画实战 我们对移动 Compose 体验的更新感到非常高兴。展望未来,我们计划继续通过响应式视觉界面丰富我们的移动体验。有兴趣与我们一起从事此类工作吗?欢迎加入我们的 Android 移动团队! 类别 芽苗工程 约翰·奥利里 John O'Leary 是 Sprout Social 移动团队的前成员。当他不开发新的 Android 功能时,他喜欢游泳、徒步旅行和吃巧克力煎饼。在 Twitter 上关注他@jholeary1。 阅读所有文章作者:约翰·奥利里 [后文]2024年工具包 为你推荐 查看全部 为你推荐 类别 芽苗工程 使用 Dependabot 自动更新依赖项 发表于 2023 年 9 月 21 日 •阅读时间 3分钟 类别 芽苗工程 迷失在翻译中:升级 Sprout Social 的本地化系统 发表于。
|
|