TextView tv = new TextView(getActivity());
LayoutParams tvLp = new LayoutParams((new LayoutParams(
0, LayoutParams.WRAP_CONTENT,1f)));
tvLp.gravity = (Gravity.BOTTOM);
tv.setLayoutParams(tvLp);
When I run the above code in pre-Kitakat devices I am getting No such method error. I found this solution Android: java.lang.NoSuchMethodError on LinearLayout$LayoutParams.<init> in which the below code is used to avoid such error. But using the below solution, I cannot programmatically set gravity,layout weights etc. Is there any workaround to solve this?
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams((ViewGroup.MarginLayoutParams)(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)));
TextView tvparent layout ?