Search code examples
androidtextviewandroid-lint

Is it possible to TextView#getMaxLines() on pre api-16 devices?


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

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) 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) 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.


Solution

  • A simpler solution was added to the support lib v4 inTextViewCompat

    int maxLines = TextViewCompat.getMaxLines(yourtextView);
    

    Check out this answer for some more informations.