我使用fontFamily作为自定义字体,但是在KitKat上,文本在textviews和button中消失了。我在下面有API 26和其他文件的单独文件。以下是<26的代码:
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:app="http://schemas.android.com/apk/res-auto">
<font app:fontStyle="normal" app:fontWeight="400" app:font="@font/calibri"/>
<font app:fontStyle="italic" app:fontWeight="400" app:font="@font/calibri_italic" />
</font-family>
following is textview :
<EditText
android:id="@+id/field_number"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="35dp"
android:layout_marginStart="8dp"
android:layout_weight="5"
android:fontFamily="@font/calibiri_font"
android:gravity="center"
android:hint="3xxxxxxxxx"
android:inputType="number"
android:maxLength="15"
android:maxLines="1"
android:scrollHorizontally="true"
android:textColor="@color/black"
android:textSize="17sp"
app:backgroundTint="@color/colorPrimaryDarkGrey"
app:layout_constraintBottom_toBottomOf="@+id/field_countrycode"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBaseline_toBaselineOf="@+id/field_countrycode"
app:layout_constraintStart_toEndOf="@+id/field_countrycode"
android:layout_marginRight="35dp"
android:layout_marginLeft="8dp" />
我无法理解这个问题,因为每件事都是根据指示。谢谢
答案 0 :(得分:0)
我已经找到解决此问题的方法。我们需要为> = v26和1为1分别创建fort.xml文件
1- font / calibri_fort.xml:
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<font
app:fontStyle="normal"
app:fontWeight="400"
app:font="@font/calibri" />
<font
app:fontStyle="italic"
app:fontWeight="400"
app:font="@font/calibri_italic" />
</font-family>
2- font-v26 // calibri_fort.xml:
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<font
android:fontStyle="normal"
android:fontWeight="400"
android:font="@font/calibri" />
<font
android:fontStyle="italic"
android:fontWeight="400"
android:font="@font/calibri_italic" />
</font-family>