0

So in my android app I have two Linear Layouts side by side with the same weight & width
One is called "LeftView" another called "RightView"
what I like to do is removing RightView and giving all the space assigned to it to LeftView ...with a click of a button while the app is running
So in the end LeftLayout becomes bigger obviously
How to achieve this guys ?

9patchcoder
  • 619
  • 1
  • 5
  • 17

1 Answers1

0

Set that LinearLayout weight to 0. I just tried that and it works for me. Here is how you can do it:

How to set layout_weight attribute dynamically from code?

Community
  • 1
  • 1
Gintas_
  • 4,940
  • 12
  • 44
  • 87
  • I've already set them to 0 and they're even by size ... but the problem is how to dispose of the rightview ...visually and programatically ! ( I mean literally killing its object) – 9patchcoder Jul 28 '14 at 20:57
  • yes, you set your layouts how you like, then programatically get layout using findViewById and use link I gave to you to set layout's weight to 0. – Gintas_ Jul 28 '14 at 21:04
  • 1
    ow sorry ... I kept mistaking weight for width... you were right homie ! Another solution I found was RightLayout.setVisibility(View.GONE); – 9patchcoder Jul 28 '14 at 21:08