Code example for LinearLayout.LayoutParams

0
    private static class ColoredView extends View {
 
        private boolean mExpanded = false;
 
        private LayoutParams mCompressedParams = new LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, 50);
 
        private LayoutParams mExpandedParams = new LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, 200);
 
        private ColoredView(Context context) {
            super(context);
            int red = (int)(Math.random() * 128 + 127);
            int green = (int)(Math.random() * 128 + 127);
            int blue = (int)(Math.random() * 128 + 127);
            int color = 0xff << 24 | (red << 16) |
                    (green << 8) | blue;
            setBackgroundColor(color);
            setLayoutParams(mCompressedParams);
            setOnClickListener(new OnClickListener() {
                @Override