【发布时间】:2012-07-03 18:39:16
【问题描述】:
我有一个FrameLayout(在RelativeLayout 内),我通过FragmentTransaction 类添加/删除Fragments。我的FrameLayout 最初与其父对象左对齐,有时通过FrameLayout.offsetLeftAndRight(int offset) 方法水平偏移。
我发现当我的FrameLayout 偏移并且我提交片段事务以向其添加Fragment(即FragmentTransaction.add(R.id.myFrameLayout, myNewFragment).commit())时,我的FrameLayout 跳回其原始位置,忽略其偏移.
任何人都知道为什么会发生这种情况,以及当我向其添加Fragment 时如何避免我的FrameLayout 重新定位?
注意:我使用的是
offsetLeftAndRight(int offset)方法而不是setTranslationX(float translationX)或其他方法,因为我需要我正在做的工作来完成Honeycomb 之前的工作。
【问题讨论】:
标签: android android-layout android-fragments android-view android-fragmentactivity