Android 折叠工具栏布局字体未更改
我有一个折叠工具栏布局,如下所示:Android 折叠工具栏布局字体未更改,android,android-layout,android-collapsingtoolbarlayout,android-fonts,Android,Android Layout,Android Collapsingtoolbarlayout,Android Fonts,我有一个折叠工具栏布局,如下所示: <android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:fitsSystemWindows="true" android:theme="@style/ThemeOverlay
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="170dp"
android:background="@color/orange"
app:contentScrim="@color/orange"
app:expandedTitleGravity="bottom|center_horizontal"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="@+id/backdrop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="30dp"
android:src="@drawable/ic_lock_profile_prime"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
我试图更改“折叠工具栏布局”的标题,但没有更改
我应该怎么做才能改变它的字体呢?试着使用它,它对我有用,并且在折叠工具栏布局中改变了字体
试着使用它,它对我有用,并且在折叠工具栏布局中更改了字体
在src/main/assets/fonts目录中添加字体,并使用以下代码:
final Typeface tf = Typeface.createFromAsset(getContext().getAssets(), "fonts/yourfont.ttf");
collapsingToolbarLayout.setCollapsedTitleTypeface(tf);
collapsingToolbarLayout.setExpandedTitleTypeface(tf);
在目录src/main/assets/fonts中添加字体,并使用以下代码:
final Typeface tf = Typeface.createFromAsset(getContext().getAssets(), "fonts/yourfont.ttf");
collapsingToolbarLayout.setCollapsedTitleTypeface(tf);
collapsingToolbarLayout.setExpandedTitleTypeface(tf);
请添加app:expandedTitleTextAppearance=“@style/TextAppearance.AppCompat.Title”特别是最后一部分。Titleit不起作用。Typeface font=Typer.set(yourContext)。getFont(font.ROBOTO_MEDIUM);collapsedtitletypeface(字体);折叠工具栏。setExpandedTitleTypeface(字体);我想使用除Roboto字体以外的字体。请添加app:expandedtitletextearance=“@style/textpearance.AppCompat.Title”,特别是最后一部分。Titleit不起作用。Typeface font=Typer.set(yourContext)。getFont(font.Roboto_MEDIUM);collapsedtitletypeface(字体);折叠工具栏。setExpandedTitleTypeface(字体);我想使用除Roboto字体以外的字体。如何使用此库更改CollasingToolbarLayout的字体?添加到build.gradle编译'uk.co.chrisjenx:书法:2.3.0'中的依赖项否。我的意思是如何设置字体?添加字体将自定义字体添加到assets/。所有字体定义都与此路径相关。假设您使用的是Gradle,那么您应该在项目目录中的src/main/下创建assets目录(如果它还不存在)。由于在Gradle中使用多项目构建非常流行,路径通常是app/src/main/assets/,其中app是项目名称。您可以考虑在资产目录中创建字体/子目录(如在示例中)。用法安装在#onCreate()方法的应用程序类中,使用CalligraphyConfig定义默认字体@重写public void onCreate(){super.onCreate();CalligraphyConfig.initDefault(new CalligraphyConfig.Builder().setDefaultFontPath(“font/Roboto robotregular.ttf”).setFontAttrId(R.attr.fontPath.build());/…}如何使用此库更改CollasingToolbarLayout的字体?添加到build.gradle compile'uk.co.chrisjenx:书法:2.3.0'中的依赖项否。我的意思是如何设置字体?添加字体将自定义字体添加到assets/。所有字体定义都与此路径相关。假设您使用的是Gradle,那么您应该在项目目录中的src/main/下创建assets目录(如果它还不存在)。由于在Gradle中使用多项目构建非常流行,路径通常是app/src/main/assets/,其中app是项目名称。您可以考虑在资产目录中创建字体/子目录(如在示例中)。用法安装在#onCreate()方法的应用程序类中,使用CalligraphyConfig定义默认字体@重写public void onCreate(){super.onCreate();CalligraphyConfig.initDefault(new CalligraphyConfig.Builder().setDefaultFontPath(“font/Roboto robotregular.ttf”).setFontAttrId(R.attr.fontPath.build());/…}