要导入什么来解决"LayoutParams无法解析为变量"?

Sun*_*mar 5 resolve android-layout layoutparams

LayoutParams cannot be resolved to a variable在一行代码上得到错误,如下所示tv.setLayoutParams(new GridView.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 0.1f));
当我按ctrl + shift + o导入必要的pacakges我得到了很多版本的包作为选项.我很困惑哪一个应该做这个工作. 是我得到的选项

导入后import android.app.ActionBar.LayoutParams;仍然出错

The constructor AbsListView.LayoutParams(int, int, float) is undefined
Run Code Online (Sandbox Code Playgroud)

Sun*_*mar 2

可以通过导入[任何布局].LayoutParams来解决,例如。 import android.widget.GridLayout.LayoutParams; 尽管我不清楚选择导入哪个包的标准应该是什么。解决问题

the constructor AbsListView.LayoutParams(int, int, float) is undefined
Run Code Online (Sandbox Code Playgroud)

确保第三个参数也是一个“int”,它应该是:

LayoutParams cannot be resolved to a variable on a line of code which is as follows tv.setLayoutParams(new GridView.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1));
Run Code Online (Sandbox Code Playgroud)