android / views-widgets-samples

Multiple samples showing the best practices in views-widgets on Android.
Apache License 2.0
5.05k stars 3.01k forks source link

CustomAttribute TextSize extremely large #53

Open olsisaqe opened 5 years ago

olsisaqe commented 5 years ago

If you try to set text size with custom attribute the end result is an extremely large text:

<CustomAttribute
                motion:attributeName="textSize"
                motion:customDimension="14sp"/>
rjkrunal commented 5 years ago

Try this

line1Size = a.getDimensionPixelSize(R.styleable.StackedTextView_line1_textSize, 0); line2Size = a.getDimensionPixelSize(R.styleable.StackedTextView_line2_textSize, 0);

if (line1Size > 0) { holdr.textLine1.setTextSize(TypedValue.COMPLEX_UNIT_PX, line1Size); } if (line2Size > 0) { holdr.textLine2.setTextSize(TypedValue.COMPLEX_UNIT_PX, line2Size); }