是否可以将Wrap Content Identifier设置为int?以下代码是否有效?
EditText ET = new EditText(getActivity());
ET.setWidth(WRAP_CONTENT);
答案 0 :(得分:4)
我想你应该做那样的事情:
EditText editTextView = new EditText(getActivity());
LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.FILL_PARENT);
editTextView.setLayoutParams(params);
答案 1 :(得分:0)
尝试通过布局参数执行此操作: 将此行添加到您的代码
ET.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));