Reputation: 265
private void generateView() {
for (int i = 0; i < 10; i++) {
mview = new LinearLayout(getActivity());
mview.setBackgroundResource(R.color.grayColor);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(10, 40);
layoutParams.setMargins(5, 0, 5, 0);
mview.setLayoutParams(layoutParams);
lnLinearlayout.addView(mview);
}
}
Using this code I am able to display views like this:
||||||||||
I want to increase the height of the views at position 4 and 8. I am trying to do so using:
lnLinearlayout.getChildAt(4).setMinimumHeight(20) lnLinearlayout.getChildAt(8).setMinimumHeight(20)
but there is no change in the views. Can anyone please suggest how to increase the height of a particular view?
Upvotes: 0
Views: 247
Reputation: 1376
try this
lnLinearlayout.getChildAt(4).setLayoutParams(new LinearLayout.LayoutParams(10, 200));
Upvotes: 0
Reputation: 265
Use below code..
LinearLayout.LayoutParams layoutParams=(LinearLayout.LayoutParams)lnLinearlayout.getChildAt(4).getLayoutParams();
layoutParams.height=20;
layoutParams=(LinearLayout.LayoutParams)lnLinearlayout.getChildAt(8).getLayoutParams();
layoutParams.height=20;
Upvotes: 1