Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

should pass resolved pixel dimension instead of resource id here:getResource().getDimession*(ViewGroup.LayoutParams.WRAP_CONTENT)

Tags:

android

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);

I want to add MarginLayoutParams to my view. But, It shows an error

should pass resolved pixel dimension instead of resource id here:getResource().getDimession*(ViewGroup.LayoutParams.WRAP_CONTENT)

How can I solve this problem?

like image 913
mashell cage Avatar asked Sep 20 '16 14:09

mashell cage


1 Answers

MATCH_PARENT and WRAP_CONTENT are indeed valid input for LayoutParams width and height.

This is hyperactive Lint in action. You can safely ignore the warning.

Select the underlined statement, press Alt+Enter, select the issue, select Ignore for statement/for method.

like image 93
Eugen Pechanec Avatar answered Nov 20 '22 01:11

Eugen Pechanec