Closed zhuzhuxiang closed 2 years ago
@zhuzhuxiang could you please provide more information?
How does the specified font look like? did you define the 3 character key as zhu
?
Do you either register the font when you set up Iconics
or have an initializer like the provided fonts?
Initializer: https://github.com/mikepenz/Android-Iconics/blob/develop/meteocons-typeface-library/src/main/java/com/mikepenz/iconics/typeface/library/meteoconcs/Initializer.kt#L8-L17 https://github.com/mikepenz/Android-Iconics/blob/develop/meteocons-typeface-library/src/main/AndroidManifest.xml#L28-L30
Drawable drawable_custom = new IconicsDrawable(this) .icon(Cniao5Font.Icon.zhu__denglong) .color(Color.GREEN) .sizeDp(150); ((ImageView) this.findViewById(R.id.image_custom)).setImageDrawable(drawable_custom); √ <TextView android:layout_width="50dp" android:layout_height="50dp" android:text="自定义字体{zhu_denglong}" /> ×
You duplicated the initial message. Please see my answer above :)
<TextView
android:layout_width="50dp"
android:layout_height="50dp"
android:text="{ion-help-buoy}" />
<ImageView
android:id="@+id/image_view"
android:layout_width="50dp"
android:layout_height="50dp" />
<TextView
android:layout_width="50dp"
android:layout_height="50dp"
android:text="{zhu_denglong}" />
<ImageView
android:id="@+id/image_custom"
android:layout_width="50dp"
android:layout_height="50dp" />
Drawable drawable = new IconicsDrawable(this)
.icon(Ionicons.Icon.ion_android_add_circle)
.color(Color.RED)
.sizeDp(100);
((ImageView) this.findViewById(R.id.image_view)).setImageDrawable(drawable);
Drawable drawable_custom = new IconicsDrawable(this)
.icon(Cniao5Font.Icon.zhu__denglong)
.color(Color.GREEN)
.sizeDp(100);
((ImageView) this.findViewById(R.id.image_custom)).setImageDrawable(drawable_custom);
The two imageviews and the first textview can be displayed. The second textview uses a custom font. I want to display icons in the form of {} like the first textview. I don't know what to do
zhu Defined. Ionicons class for custom font rewriting
@Override
public String getMappingPrefix() {
return "zhu";
}
public enum Icon implements IIcon {
zhu_gu('\ue60a'),
zhu__chahu('\ue60b'),
zhu__xianglu('\ue60c'),
zhu__denglong('\ue60d'),
zhu__fudao('\ue60e');
//only required if you add a custom or generic font on your own
Iconics.init(getApplicationContext());
//register custom fonts like this (or also provide a font definition file)
Iconics.registerFont(new Cniao5Font());
I'm registered
第一个TextView xml android:text="{ion-help-buoy}"
The Icon
class enum should only have a single _
for the names.
See one off the icons provided from the library here: https://github.com/mikepenz/Android-Iconics/blob/develop/meteocons-typeface-library/src/main/java/com/mikepenz/iconics/typeface/library/meteoconcs/Meteoconcs.kt
I also see you use Java. Only the latest version of the library is fully supported which is targeted for Kotlin.
thanks for this topic! registering my custom font in Application class was the thing that I forgot:
Iconics.init(getApplicationContext());
Iconics.registerFont( MaterialDesignIcon.INSTANCE );