Search code examples
androidtextviewtext-size

Adjust text size as per the device specifications


I know this question has been answered many times, and i have tried almost all solution available here, but none of them seems to be working in my case.

I want to set the text size of each textview component in the manner that it automatically gets adjusted on different device sizes. Let's say i have a heading, body and source text fields and the heading size would be greater than that of body and source text sizes. Currently if i am trying some solutions by setting the text sizes as per the device density, but on some device it's perfect and on some device it's coming very small.

I have tried these solutions: Text size and different android screen sizes

Android set TextView text size to look the same on all screen sizes

Any help would be highly appreciated.


Solution

  • This is one of the best library. I used in many of my projects

    https://github.com/intuit/ssp <--- for textviews size (sp)

    https://github.com/intuit/sdp <--- for views size (dp)

    You have just put this line in your app level gradle

    implementation 'com.intuit.ssp:ssp-android:1.0.6'
    
    implementation 'com.intuit.ssp:sdp-android:1.0.6'