tAutoSizeTextTypeUniformWithPresetSizes(myTextView, sizes, TypedValue. Int sizes = getContext().getResources().getIntArray(R.tosize_text_sizes) Or you can do in Java/Kotlin like this: tAutoSizeTextTypeUniformWithPresetSizes(int presetSizes, int unit) access the array as a resource, define the array in the res/values/arrays.xml file. In XML, Use the autoSizePresetSizesautoSizePresetSizes attribute in the layout file. using a font size dictated by the position of the SeekBar in the first fragment. tAutoSizeTextTypeUniformWithConfiguration(myTextView, 12, 100, 2, TypedValue.COMPLEX_UNIT_SP) īy using preset sizes, you can autosize the TextView from a list of predefined sizes. Developing Android 9 Apps Using Android Studio 3.3, Kotlin and Android. Or, in Java/Kotlin, we can do it by calling this method: tAutoSizeTextTypeUniformWithConfiguration(TextView textview, int autoSizeMinTextSize, int autoSizeMaxTextSize, int autoSizeStepGranularity, int unit) In XML, we can do it by adding these lines in our TextView: app:autoSizeMaxTextSize=”100sp” Each increment takes on the step size specified in the granularity attribute. In Granularity, The TextView can uniformly scale, in a range between the given minimum and maximum size attributes. So far, we have only saw the default uniform auto size text type, but there are two more ways to adjust text size as per our needs: Please note that if you set autosizing in an XML file, it is not recommended to use the value "wrap_content" for the layout_width or layout_height attributes of a TextView. You can also do this from Java/Kotlin using this line tAutoSizeTextTypeWithDefaults(myTextView, TextViewCompat.AUTO_SIZE_TEXT_TYPE_UNIFORM)
0 Comments
Leave a Reply. |