Я думаю, что вы хотите сделать так:
TranslateAnimation animateGroups = new TranslateAnimation(0,widthScreen - 40 , 0 , 0);
animateGroups.setDuration(1200);
animateGroups.setFillAfter(true);
TranslateAnimation animateSubGroups = new TranslateAnimation(0,widthScreen - 10 , 0 , 0);
animateSubGroups.setDuration(1200);
animateSubGroups.setFillAfter(true);
scrollViewGroups.startAnimation(animateGroups);
scrollViewSubGroups.startAnimation(animateSubGroups);
Примечание: вы можете получить размеры экрана с помощью DiplayMetrics
класса, и еслиВы хотите преобразовать пиксели в dp, см. this
EDIT : Измените место ваших просмотров после окончания анимации , чтобы сделать это, вы должны добавить Listener На вашей анимации,
animateGroups.addAnimationListener(AnimationListener);
и переопределить метод следующим образом:
@Override
public void onAnimationEnd(Animation animation){
scrollViewGroups.setPadding(0, 0 , screenWidth-40 , 0 ) ;
//or you can set the Margin like this(i supposed that your scrollView is in a RelativeLayout
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)scrollViewGroups.getLayoutParams();
params.setMargin(0, 0 , screenWidth-40 , 0);
scrollViewGroups.setLayoutParams(params);
}