我在为 Android fragment 使用共享元素转换时遇到了一个小问题。我正在尝试在两个 fragment 之间移动 TextView。我设法让它成功过渡,但是,当我尝试返回到源 fragment 时,Textview android:gravity 似乎停滞不前。在源代码 fragment 中,textview gravity 定义为:
android:gravity="end"
而在目标 fragment 中,textview gravity 定义为:
android:gravity="center"
当我从源 fragment 转到目标 fragment 时,一切正常。但是,当我点击后退按钮时,共享 TextView 会移动到中心位置。
有人可以指点一下吗?谢谢。
转换定义为:
<?xml version="1.0" encoding="utf-8"?>
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android">
<changeTransform/>
<changeBounds/>
</transitionSet>
最佳答案
没关系!弄清楚了。我将 textview 包裹在水平线性布局中。 TextView 的宽度和高度设置为“wrap_content”。
关于android - 共享元素转换中的 TextView 引力,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28829336/