是否可以在api-16之前的设备上使用TextView#getMaxLines()? [英] Is it possible to TextView#getMaxLines() on pre api-16 devices?

查看:117
本文介绍了是否可以在api-16之前的设备上使用TextView#getMaxLines()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用程序中使用了 TextView#getMaxLines()了几周而没有发生事故。

I used TextView#getMaxLines() in my application for a few weeks without incident.

Lint是现在通知我它仅在API 16+中可用( #setMaxLines()是API 1 + ...),尽管(据我所知)我还没有' t修改了会导致此突然标记的任何内容-我的min-sdk已经8了一段时间,并且我在源代码管理中有文件对此进行了证明。

Lint is now informing me that it's only available in API 16+ (#setMaxLines() is API 1+...), though (to the best of my knowledge) I haven't modified anything that would cause this sudden flag - my min-sdk has been 8 for a while, and I have files in my source control to prove it.

1)为什么皮棉会随机标记此错误? (要明确地说,我的意思是说它应该在最初就被抓住了-我并不是在暗示它根本不应该被标记出来。)

1) Why could lint be flagging this error randomly? (To be clear, I mean to say that it should have caught it initially - I'm not implying this is something that it shouldn't have flagged at all).

2)有什么方法可以在API 16之前的设备上检索TextView的maxLines?我检查了 ,但无法设计一种方法来使用 2.2设备

2) Is there any way to retrieve the maxLines for a TextView on pre-api 16 devices? I checked the source but couldn't devise a way to retrieve this value using the exposed methods on a 2.2 device.

推荐答案

在<$>中的 support lib v4 中添加了一个更简单的解决方案c $ c> TextViewCompat

A simpler solution was added to the support lib v4 inTextViewCompat

int maxLines = TextViewCompat.getMaxLines(yourtextView);

签出答案以获取更多信息。

Check out this answer for some more informations.

这篇关于是否可以在api-16之前的设备上使用TextView#getMaxLines()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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