【发布时间】:2020-05-20 17:38:38
【问题描述】:
我在我的风格中使用font-family,如下所示:
<?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"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="UnusedAttribute">
<font
app:font="@font/montserrat_regular"
app:fontWeight="400"
android:font="@font/montserrat_regular"
android:fontWeight="400" />
<font
app:font="@font/montserrat_bold"
app:fontWeight="700"
android:font="@font/montserrat_bold"
android:fontWeight="700"/>
</font-family>
在主题中:
<!-- font family -->
<item name="android:fontFamily">@font/mobile_font</item>
<item name="fontFamily">@font/mobile_font</item>
这是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="model"
type="main.dashboard.UserContactItem" />
</data>
<RelativeLayout
android:layout_width="@dimen/material_size_96"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tvName"
style="@style/Caption"
asyncText="@{model.title}"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/ivProfile"
android:layout_marginTop="@dimen/material_size_8"
android:gravity="center"
android:textColor="?android:attr/textColorPrimary"/>
</RelativeLayout>
</layout>
当项目出现在应用程序的屏幕上时,首先,textview 以 Android 的默认字体显示,然后一秒钟后,字体设置为 textview。 有什么问题?
【问题讨论】:
标签: android styles material-design