Search code examples
androidfont-awesomescreen-size

How to make Font Awesome icons responsive with all screen sizes in Android


I want to use Font Awesome Icons in my Android app and I'm afraid of that Font Awesome icons won't be responsive with all screen sizes . So how to make them be fit and responsive for all screen sizes

Here is an example of my Icon text

in activity_main.xml

<TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="&#xf004;"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"

        android:id="@+id/tvIcon1"
        android:textSize="500sp"
        />

in MainActivity

 Typeface typeface = ResourcesCompat.getFont(this, R.font.fa_regular_400);
       
        tvIcon1.setTypeface(typeface);

Solution

  • you can use library for responsive font or imageview or button etc for sdp library or ssp library in your gradle file which reduce your problem about it. then you can use anywhere in your project.

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

    import these library in dependencies folder then it will automatically popup their name as like @dimen/_16sdp etc