如何更改 android 中字体图标的颜色
How to change color of font icons in android
我正在制作一个聊天应用程序,我正在使用带有参考的图标字体 font awesome,我已将 ttf 文件保存到我的项目资产文件夹中,之后我通过设置字体访问图标,问题是我想改变图标的大小和颜色 font.Please 帮帮我
<TextView
android:id="@+id/landing_drawer_image"
android:layout_width="@dimen/width_40"
android:layout_height="@dimen/height_40"
android:layout_marginLeft="@dimen/margin_15"
android:textColor="@color/grey_black_1000"
android:gravity="center_vertical"
android:text="Drawable"
/>
viewHolder.drawerItemImage.setText("A");
你可以试试这个:
在 colors.xml 中设置颜色:
<color name="test">#0f0f0f</color>
在您的 XML 中执行此操作:
<TextView
android:id="@+id/landing_drawer_image"
android:layout_width="@dimen/width_40"
android:layout_height="@dimen/height_40"
android:layout_marginLeft="@dimen/margin_15"
android:textColor="@color/test"
android:gravity="center_vertical"
android:text="Drawable"
/>
要设置 TypeFace
您可以通过两种方式完成
1.-
Typeface font = Typeface.createFromAsset(
getContext().getAssets(),
"fonts/YourTypeFace.ttf");
YourTextView.setTypeface(font);
2.- android:typeface="YOURTTF"
要设置 TextSize
,您必须在 xml 文件中添加
android:textSize="@dimen/font_size"/>
试试这个,如果您有任何问题请告诉我,希望我的回答对您有所帮助 :)
试试这个
Typeface font = Typeface.createFromAsset(getAssets(),
"fontawesome-webfont.ttf");
gmail_icon.setTypeface(font);
gmail_icon.setTextColor(getResources().getColor(R.color.white));
我正在制作一个聊天应用程序,我正在使用带有参考的图标字体 font awesome,我已将 ttf 文件保存到我的项目资产文件夹中,之后我通过设置字体访问图标,问题是我想改变图标的大小和颜色 font.Please 帮帮我
<TextView
android:id="@+id/landing_drawer_image"
android:layout_width="@dimen/width_40"
android:layout_height="@dimen/height_40"
android:layout_marginLeft="@dimen/margin_15"
android:textColor="@color/grey_black_1000"
android:gravity="center_vertical"
android:text="Drawable"
/>
viewHolder.drawerItemImage.setText("A");
你可以试试这个:
在 colors.xml 中设置颜色:
<color name="test">#0f0f0f</color>
在您的 XML 中执行此操作:
<TextView
android:id="@+id/landing_drawer_image"
android:layout_width="@dimen/width_40"
android:layout_height="@dimen/height_40"
android:layout_marginLeft="@dimen/margin_15"
android:textColor="@color/test"
android:gravity="center_vertical"
android:text="Drawable"
/>
要设置 TypeFace
您可以通过两种方式完成
1.-
Typeface font = Typeface.createFromAsset(
getContext().getAssets(),
"fonts/YourTypeFace.ttf");
YourTextView.setTypeface(font);
2.- android:typeface="YOURTTF"
要设置 TextSize
,您必须在 xml 文件中添加
android:textSize="@dimen/font_size"/>
试试这个,如果您有任何问题请告诉我,希望我的回答对您有所帮助 :)
试试这个
Typeface font = Typeface.createFromAsset(getAssets(),
"fontawesome-webfont.ttf");
gmail_icon.setTypeface(font);
gmail_icon.setTextColor(getResources().getColor(R.color.white));