I currently use LayoutParams to set layout_width and layout_height programmatically:
ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 215);
tvText.setLayoutParams(lp);
Now I want so set the weight, but the "code can't be resolved". This both ways don't work:
ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 215, 1f);
tvText.setLayoutParams(lp)
ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 215);
lp.weight=1;
tvText.setLayoutParams(lp);