I\'m trying to do the following. Create a new Fragement B (Menu), slide it in from the right, and i want to move (no hide or replace!) the already shown Fragment A to the left.
Solution:
Create Relative Layout with overlapping fragments:
and simply call .translationX(-1 * mScreenWidth)
(mScreenWidth is my ScreenWidth minus the gap you want).
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB_MR1) {
((RelativeLayout) findViewById(R.id.front_frame)).animate()
.translationX(-1 * mScreenWidth);
} else {
TranslateAnimation slideOut = new TranslateAnimation(0, -1
* mScreenWidth, 0, 0);
slideOut.setDuration(getResources().getInteger(
R.integer.animation_transistion_length_short));
slideOut.setFillEnabled(true);
slideOut.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {}
@Override
public void onAnimationRepeat(Animation animation) {}
@Override
public void onAnimationEnd(Animation animation) {
RelativeLayout mView = (RelativeLayout) findViewById(R.id.front_frame);
int[] pos = { mView.getLeft() - mScreenWidth,
mView.getTop(), mView.getRight(),
mView.getBottom() };
mView.layout(pos[0], pos[1], pos[2], pos[3]);
}
});
((RelativeLayout) findViewById(R.id.front_frame))
.startAnimation(slideOut);
}