Android Question TextView setAutoSizeTextTypeWithDefaults for Android Versions less than 8.0?

skaliwag

Member
Licensed User
Longtime User
Auto-sizing text views were introduced in API 26.
I am currently trying these out using this simple code

B4X:
Public Sub SetAutoTextSize(Ctrl As Object)
    Dim r As Reflector
    r.Target = Ctrl
    r.RunMethod2("setAutoSizeTextTypeWithDefaults", "1", "java.lang.int")
End Sub

This works fine on Android 8.0, but does not work at all on earlier versions - it reports that the method is not found.

The documentation at
https://developer.android.com/guide/topics/ui/look-and-feel/autosizing-textview
states
The Support Library 26.0 provides full support to the autosizing TextView feature on devices running Android versions prior to Android 8.0 (API level 26). The library provides support to Android 4.0 (API level 14) and higher. The android.support.v4.widget package contains the TextViewCompat class to access features in a backward-compatible fashion.

How can I add this support to my B4A projects for version of Android less than 8.0?
 
Top