TextView autoSizeTextType在Compat中不起作用 [英] TextView autoSizeTextType not working in Compat

查看:307
本文介绍了TextView autoSizeTextType在Compat中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用autoSizeTextType. 我的 minSdk 是24,所有工具是26,并且 compat ist 26-beta2也是如此.

I tried using autoSizeTextType. My minSdk is 24, all the tools are 26 and compat ist 26-beta2 as well.

通过代码尝试使它们可调:

Making them adjustable was tried through code:

dialogWeight.touchables.filterIsInstance<Button>().forEach {
TextViewCompat.setAutoSizeTextTypeWithDefaults(it, 
TextViewCompat.AUTO_SIZE_TEXT_TYPE_UNIFORM) }

和xml:

<android.support.v7.widget.AppCompatTextView
android:layout_height="match_parent"
android:text="7"
android:autoSizeTextType="uniform"/>

有什么想法吗?我开始相信它目前存在错误

Any ideas ? I'm starting to believe that it's currently bugged

推荐答案

好的,因此有效的设置组合是:

Okay, so the combination of settings that worked :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<android.support.v7.widget.AppCompatTextView
android:text="7"
app:autoSizeTextType="uniform"/>

您还需要appcompat-v7库作为模块build.gradle文件中的依赖项.

You also need the appcompat-v7 library as a dependency in your module build.gradle file.

dependencies {
    implementation 'com.android.support:appcompat-v7:27.1.1'
}

这篇关于TextView autoSizeTextType在Compat中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆