Moving layout position programmatically in linear layout

try like this....

ImageView imageView= (ImageView)yourLinearLayout.findViewById(R.id.thumbPhoto);
yourLinearLayout.removeViewAt(1);
yourLinearLayout.addView(0, imageView);

By using this line

// How should i change the position of my ImageView ??
        wrapper.setGravity([some_condition] ? Gravity.LEFT : Gravity.RIGHT);

It shows no effect. Because here you are applying gravity to linearlayout, this gravity aligns its whole content either in left or right.