简体   繁体   English

如何使 Font Awesome 图标响应 Android 中的所有屏幕尺寸

[英]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 .我想在我的 Android 应用程序中使用 Font Awesome Icons,但我担心 Font Awesome 图标无法响应所有屏幕尺寸。 So how to make them be fit and responsive for all screen sizes那么如何使它们适合所有屏幕尺寸并做出响应

Here is an example of my Icon text这是我的图标文本的示例

in activity_main.xmlactivity_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 MainActivityMainActivity

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

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.您可以将库用于响应式字体或图像视图或按钮等,用于 gradle 文件中的 sdp 库或 ssp 库,从而减少您的问题。 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'实现 'com.intuit.sdp:sdp-android:1.0.6' 实现 '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在依赖文件夹中导入这些库然后它会自动弹出他们的名字,如@dimen/_16sdp 等

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM