【发布时间】:2017-11-08 16:45:34
【问题描述】:
我正在寻找自动更改 TextView 大小。我也找到了解决方案。这是用于自动调整文本视图大小的官方Doc。但我仍然无法解决它。当我粘贴 autoSizeTextType 时,它在 xml 文件中显示错误。
这是我的xml代码和gradle代码sn-ps
我的活动.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical">
<include layout="@layout/toolbar" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:autoSizeTextType="uniform"/>
</LinearLayout>
Gradle sn-p
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:support-v4:25.2.0'//Added support library
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:design:25.2.0'
testCompile 'junit:junit:4.12'
}
【问题讨论】:
-
Autosizing TextViews 是 Android O 的一项新功能(下一个 Android 版本尚未发布),如文档中所述,尚不适用于以前的版本。这就是它向您显示错误的原因。
标签: android xml textview android-support-library