Andy Andy - 1 year ago 79
Android Question

Changing WRAP_CONTENT to a set number using LinearLayout.LayoutParams

I have set up some

to set up some buttons just using java. But I want to change it from
to a height and width of my choice.

//LinearLayout.LayoutParams top;
//this is declared at the top as it is used by different bits of the code.
top = new LinearLayout.LayoutParams
(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
top.topMargin = 100;
top.leftMargin = 120;

Answer Source
top = new LinearLayout.LayoutParams
            (90, 80); 

// whatever u like

this is from documentation:

public LayoutParams(int width, int height) {
        super(width, height);
        weight = 0;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download