grantland / android-autofittextview

A TextView that automatically resizes text to fit perfectly within its bounds.
Apache License 2.0
4.27k stars 688 forks source link

Adding autofitextview from java code not working #80

Open yeahia2508 opened 7 years ago

yeahia2508 commented 7 years ago

I'm trying to add autotextview from java code but not working .

AutofitTextView ivBowl = new AutofitTextView(this); ivBowl.setText(text); ivBowl.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30); ivBowl.setTextColor(Color.parseColor("#00463E")); ivBowl.setMinTextSize(TypedValue.COMPLEX_UNIT_SP,18); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParams.setMargins(5, 10, 0, 0); // left, top, right, bottom ivBowl.setLayoutParams(layoutParams); row2.addView(ivBowl);