1

Set layout_gravity to center for custom LinearLayout

view story
linux-howto

http://stackoverflow.com – I am creating a custom LinearLayout just to measure and properly resize it: public class Frame extends LinearLayout { private int width; private int height; private Context context; public Frame(Context context, AttributeSet attrs) { super(context, attrs); this.context=context; } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int height = MeasureSpec.getSize(heightMeasureSpec); int width = MeasureSpec.getSize(widthMeasureSpec); int newwidth=MeasureSpec .makeMeasureSpec(height*480/720,MeasureSpec.EXACTLY); (HowTos)