Android如何更改操作栏设置文本的大小?

时间:2015-06-16 06:21:22

标签: android android-actionbar

我想更改操作栏标题文字大小。我该怎么办呢?

    ActionBar actionBar = getSupportActionBar();
    actionBar = getSupportActionBar();
    actionBar.setLogo(R.drawable.tg_logo_new);
    actionBar.setDisplayUseLogoEnabled(true);
    actionBar.setDisplayShowHomeEnabled(true);
    actionBar.show();
    actionBar.setTitle("Header");

2 个答案:

答案 0 :(得分:0)

你也可以这样做..

android.support.v7.app.ActionBar actionBar = getSupportActionBar();
actionBar.setTitle(Html.fromHtml(" <b> YOUR TITLE </b> "));
在fromHtml()中,您可以使用任何标记<b>如果您想要更大的尺寸,也可以使用<h2>,<h3>, .., <h6>

就是这样 你可以做到

    b = getIntent().getExtras(); 
    if (b != null) { 
          String Description = b.getString("Description"); 
          android.support.v7.app.ActionBar actionBar = getSupportActionBar();
          actionBar.setTitle(Html.fromHtml("<b>" +Description+ "</b>"));
    }

答案 1 :(得分:-1)

试试这个,会解决你的问题:

<style name="Theme.YourTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="android:actionBarStyle">@style/Theme.YourTheme.Styled.ActionBar</item>
    </style>

    <style name="Theme.YourTheme.Styled.ActionBar" parent="Theme.YourTheme">
        <item name="android:titleTextStyle">@style/Theme.YourTheme.Styled.ActionBar.TitleTextStyle</item>
    </style>

    <style name="Theme.YourTheme.Styled.ActionBar.TitleTextStyle" parent="@android:style/Widget.TextView">
        <item name="android:textSize">12sp</item>
    </style>

它需要API 11及更高版本

相关问题