Reputation: 4373
I spent several hours trying to do this, but finally I gave up.
I have a LinearLayout. Inside of it I have another LinearLayout that is initially hidden. When some condition occurs, I need that hidden layout to be shown and the containing layout to expand its height in order to show the shown layout.
I can detect that the layout is shown, however, containing layout does not expand. The problem is that after containing layout is another layout that I need to be moved down so that the new layout can be seen.
This I have done at last:
sublay.setVisibility(View.VISIBLE);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
layout.setLayoutParams(lp);
layout.requestLayout();
Of course, that did not work. How can I do it?
Upvotes: 0
Views: 331
Reputation: 81
Try
sublay.getLayoutParams().height = MATCH_PARENT;
sublay.getLayoutParams().width = MATCH_PARENT;
Upvotes: 1