How to put the percentage of the weight of 2 Edittext fields via code without using xml?

0

I have two EdiText fields, name and age I need the name field to get 70% of the line and age at 30%, in xml it's easy to solve this, but in Java code I'm not getting it, does anyone know how to do it? Thank you in advance!

I'm using this code to set the parameters.

LayoutParams param5 = new LayoutParams(LayoutParams.MATCH_PARENT,
                LayoutParams.WRAP_CONTENT, X);
        nome_edit.setLayoutParams(param5);

Note: I tried to leave the first parameter of LayoutParams at 0 and put a value in place of X but it did not work.

    
asked by anonymous 14.09.2015 / 21:24

1 answer

0

I was able to solve it! follow the code:

LinearLayout.LayoutParams lp1 = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 0.7f); 0.7 é a porcentagem, coloquei 0.3 para a idade
        nome_edittext.setLayoutParams(lp1);
    
14.09.2015 / 21:52