Back to project page android-movies-demo.
The source code is released under:
MIT License
If you think the Android project android-movies-demo listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.idunnolol.moviesdemo.view; //ww w .ja v a 2 s . c o m import android.content.Context; import android.util.AttributeSet; import android.view.View; import android.widget.RelativeLayout; /** * As this is translated, its children get translated back in the opposite direction * This has the effect of making it look "centered" even though it is sliding. */ public class CenteringRelativeLayout extends RelativeLayout { public CenteringRelativeLayout(Context context) { super(context); } public CenteringRelativeLayout(Context context, AttributeSet attrs) { super(context, attrs); } public CenteringRelativeLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override public void setTranslationX(float translationX) { super.setTranslationX(translationX); float childCounter = -translationX / 2; int childCount = getChildCount(); for (int a = 0; a < childCount; a++) { View child = getChildAt(a); child.setTranslationX(childCounter); } } }