我正在将 LinearLayout
从其原始高度调整为 0
,方法是:
ViewGroup.LayoutParams params = getLayoutParams();
params.height = newHeight;
requestLayout();
除 newHeight = 0
外一切正常 - 布局的高度变回其原始高度。我怎样才能避免它?
如果 newHeight == 0
没有帮助,则将可见性设置为 GONE
。
最佳答案
试试这个.....
LinearLayout layout = (LinearLayout)findViewById(R.id.yourLayoutId);
LinearLayout.LayoutParams lp = (LayoutParams) layout.getLayoutParams();
lp.height = 0;
关于android - 以编程方式将 LinearLayout 高度更改为 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12245371/