1

我正在制作一个聊天应用程序,我正在使用带有参考字体的图标字体真棒,我已将 ttf 文件保存到我的项目资产文件夹中,之后我通过设置字体访问图标,问题是我想更改图标的大小和颜色字体。请帮帮我

 <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");
4

2 回答 2

3

尝试这个

    Typeface font = Typeface.createFromAsset(getAssets(),
            "fontawesome-webfont.ttf");

    gmail_icon.setTypeface(font);

    gmail_icon.setTextColor(getResources().getColor(R.color.white));
于 2015-02-23T11:16:35.447 回答
2

你可以试试这个:

在您的 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"/>

试试这个,如果你有任何问题让我知道,希望我的回答能以某种方式帮助你:)

于 2015-02-23T10:59:09.590 回答