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)
我该如何解决这个问题?
答案 0 :(得分:11)
function lc(canv, x1, y1, x2, y2) {
c = canv.getContext("2d");
c.beginPath();
c.moveTo(x1, y1);
c.lineTo(x2, y2);
c.strokeStyle = "red";
c.stroke();
return c
}
var canvas = document.getElementById("myCanvas");
var ctx = canvas.getContext("2d");
ctx.beginPath();
ctx.moveTo(0, 0);
ctx.lineTo(200, 100);
ctx.stroke();
ctx.drawImage(lc(canvas, 15, 56, 56, 75), 10, 10);
ctx.drawImage(lc(canvas, 25, 56, 156, 95), 80, 80);
和MATCH_PARENT
确实是WRAP_CONTENT
宽度和高度的有效输入。
这是过度活跃的Lint。您可以放心地忽略警告。
选择带下划线的语句,按Alt + Enter,选择问题,选择忽略语句/方法。