TextView textView = new TextView(getActivity()); textView.setBackgroundResource(R.drawable.shape_item_talker_realm); textView.setText(skill.skill_name); textView.setTextSize(12); textView.setPadding(12, 12, 12, 12); textView.setTextColor(ContextCompat.getColor(getContext(), R.color.userIndexTagText)); ViewGroup.MarginLayoutParams lp = new ViewGroup.MarginLayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT ); lp.setMargins(0, 0, 15, 15);
我想在我的视图中添加MarginLayoutParams
。 但是,它显示错误
应该在这里传递已解析的像素维度而不是资源ID:
getResource().getDimession*(ViewGroup.LayoutParams.WRAP_CONTENT)
我怎么解决这个问题?
MATCH_PARENT
和WRAP_CONTENT
确实是LayoutParams
宽度和高度的有效输入。
这是过度活跃的林特 。 您可以放心地忽略该警告。
选择带下划线的语句,按Alt + Enter,选择问题,选择Ignore for statement / for method。