I am resizign LinearLayout
from it's original height to 0
with:
ViewGroup.LayoutParams params = getLayoutParams();
params.height = newHeight;
requestLayout();
Everything works except newHeight = 0
- layout's height changes back to its original height. How can I avoid it ?
Setting visibility to GONE
if newHeight == 0
does not help.
This can also be done with a linear layout. Just provide Height = 0dp and weight = 1 in the layout above, and the one you want at the bottom is just write height = line feed content, not weight.
This constant was deprecated in API level 28.
To center align LinearLayout, assign android:gravity attribute of this LinearLayout with the value “center”. Let us create an Android application with LinearLayout containing two Button widgets as children. We shall center align these children using gravity attribute.
Try this.....
LinearLayout layout = (LinearLayout)findViewById(R.id.yourLayoutId);
LinearLayout.LayoutParams lp = (LayoutParams) layout.getLayoutParams();
lp.height = 0;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With