如何使用setLayoutParams

时间:2015-03-22 10:22:02

标签: android-linearlayout

我正在等待扩展和收缩线性布局。

线性布局高度将在开头设置为0dp像素,一旦用户选择某个按钮,则布局高度将扩展为MATCH_PARENT

用户再次选择按钮后,线性布局的高度再次为0dp

请任何帮助都会很棒。谢谢。

1 个答案:

答案 0 :(得分:0)

您可以尝试使用以下内容将高度设置为0

// Get your linearlayout
LinearLayout layout = (LinearLayout)findViewById(R.id.mylinearlayout);
// Gets the layout params that will allow you to resize the layout
LayoutParams params = layout.getLayoutParams();
// Changes the height and width to the specified *pixels*
params.height = 0;
相关问题