January 24th, 2012, 03:10 PM
|
#1 (permalink)
|
|
Junior Member
Join Date: Jan 2012
Location: Brazil - Blumenau, SC
Posts: 69
Device(s): Motorola Defy - Gingerbread(2.3.3)
Thanks: 12
Thanked 5 Times in 4 Posts
|
Problem with setLayoutParams and weight
I'm having problem changing the weight of a view by code.
I have two views, each one with weight of 1, when I change the weight of one to 2, then the opposite occurs, the view that have weight 1 occupies 66% of the screen and the view that have weight 2 occupies 33% of the screen.
The code:
View view = findViewById(R.id.view1);
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams)view.getLayoutParams();
params.weight += 1f;
view.setLayoutParams(params);
|
|
|