Android 如何通过编程将AutoSizeText类型转换为unifrom?
这是可能的Android 如何通过编程将AutoSizeText类型转换为unifrom?,android,textview,Android,Textview,这是可能的 <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:autoSizeTextType="uniform" android:maxLines="1" /> 这两个都需要配置,但我希望成为默认配置,与android:autoSizeTextType=“uniform”相同 上面说: AppCompatTextVie
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autoSizeTextType="uniform"
android:maxLines="1" />
这两个都需要配置,但我希望成为默认配置,与android:autoSizeTextType=“uniform”相同
上面说:
AppCompatTextView.setAutoSizeTextTypeWithDefaults can only be called from within the same library group (groupId=com.android.support).
PS:我将代码总结为:
if(android.os.Build.VERSION.SDK_INT= > 26) {...}
您可以使用
TextViewCompat
类来避免库限制错误。像
TextViewCompat.setAutoSizeTextTypeWithDefaults(textView,TextView.AUTO_SIZE_TEXT_TYPE_UNIFORM);
您可以使用
TextViewCompat
类来避免库限制错误。像
TextViewCompat.setAutoSizeTextTypeWithDefaults(textView,TextView.AUTO_SIZE_TEXT_TYPE_UNIFORM);
TextView TextView=findviewbyd(R.id.text\u视图);TextViewCompat.setAutoSizeTextTypeWithDefaults(textview,TextViewCompat.AUTO_SIZE_TEXT_TYPE_UNIFORM);TextView TextView=findviewbyd(R.id.text\u视图);TextViewCompat.setAutoSizeTextTypeWithDefaults(textview,TextViewCompat.AUTO_SIZE_TEXT_TYPE_UNIFORM);
TextViewCompat.setAutoSizeTextTypeWithDefaults(textView,TextView.AUTO_SIZE_TEXT_TYPE_UNIFORM);