如何根据Android中文本的长度动态自动调整TextView的大小? [英] How to auto size textview dynamically according to the length of the text in android?

查看:692
本文介绍了如何根据Android中文本的长度动态自动调整TextView的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从服务器获取可变大小的数据并将其设置为textView,我希望textview根据文本集的长度来调整大小.

I am taking data of variable sizes from the server and setting to a textView and i wanted the textview to resize according to the length of the text set.

在材料设计指南中给出.如何进行编码?

It is given in the material design guidelines. How to go about coding it ?

链接到指南- https://material.google .com/style/typography.html#typography-other-typographic-guidelines

推荐答案

现在有一个官方的解决方案.支持库26中提供了随Android O引入的自动调整TextView的大小,并且一直向下兼容到Android 4.0.

There's now an official solution to this problem. Autosizing TextViews introduced with Android O are available in the Support Library 26 and is backwards compatible all the way down to Android 4.0.

https://developer.android.com/preview/features/autosizing- textview.html

这篇关于如何根据Android中文本的长度动态自动调整TextView的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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