gpt4 book ai didi

android - 更改默认 ActionBar 的字体

转载 作者:行者123 更新时间:2023-11-29 01:10:22 24 4
gpt4 key购买 nike

我想更改 ActionBar 标题的字体。我发现了很多关于此搜索的结果(example1example2example3example4),但任何一个都解决了我的问题。

我想更改默认 ActionBar 的字体,它没有任何可以调用的 TextView 项并修改字体。我知道我可以创建自定义 ActionBar,但我想尝试在没有自定义 ActionBar 的情况下执行此操作。

这是我的代码:

MainActivity.java

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main1);
...

ma​​in1.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/mapa"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>

</RelativeLayout>

ActionBar 结果:

enter image description here

我能做什么?

谢谢大家。

最佳答案

要改变textview的字体你可以使用Calligraphy library

如果你想在没有自定义 View 的情况下改变 ActionBar 的外观,你可以使用样式。对于 AppTheme,您可以设置自定义 actionBarStyle。

    <style name="MyCustomActionBarStyle" parent="@style/Widget.AppCompat.ActionBar">
<item name="android:titleTextStyle">@style/MyCustomTextStyleWithFont</item>
</style>

关于android - 更改默认 ActionBar 的字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43642913/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com