Code example for LinearLayout

Methods: setBackgroundColorsetPaddingaddViewsetOrientation

0
                LinearLayout.LayoutParams.FILL_PARENT,
                LinearLayout.LayoutParams.FILL_PARENT));
        tscroll.addView(textView);
 
        // Add a layout to hold the buttons. 
        buttonHolder = new LinearLayout(context);
        buttonHolder.setBackgroundColor(0xf08080);
        buttonHolder.setOrientation(LinearLayout.HORIZONTAL);
        buttonHolder.setPadding(6, 3, 3, 3);
        layout.addView(buttonHolder, new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.FILL_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));
 
        // Add the OK button. 
        Button btn = new Button(context);
        btn.setText(buttonLabelId);
        btn.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                dismiss();
            } 
        }); 
        buttonHolder.addView(btn, new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT, 1));
 
        return layout;
    }