我在我的资源文件夹中使用了fontawesome webfont.ttf字体文件。
我的布局文件:
<TextView
android:id="@+id/shop_search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="5"
android:gravity="center"
android:text="@string/fa_search"
android:textColor="@color/gray"
android:textSize="25sp" />我的字符串文件:
<string name="fa_hourglass"></string>我的java文件:
itemView = (TextView) itemView.findViewById(R.id.item);
Typeface font = Typeface.createFromAsset(mContext.getAssets(), "fontawesome-webfont.ttf");
itemView .setTypeface(font);发布于 2017-01-18 18:23:53
因为在string.xml文件中定义了字符串
<string name="fa_hourglass"></string>但在TextView中您使用了错误的字符串
android:text="@string/fa_search"所以把文本改成这样
android:text="@string/fa_hourglass"https://stackoverflow.com/questions/41716684
复制相似问题