小编mas*_*age的帖子

应该在这里传递已解析的像素维度而不是资源ID:getResource().getDimession*(ViewGroup.LayoutParams.WRAP_CONTENT)

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);
Run Code Online (Sandbox Code Playgroud)

我想添加MarginLayoutParams到我的视图中.但是,它显示错误

应该在这里传递解析的像素维度而不是资源ID:getResource().getDimession*(ViewGroup.LayoutParams.WRAP_CONTENT)

我怎么解决这个问题?

android

6
推荐指数
1
解决办法
2615
查看次数

标签 统计

android ×1