Android的工具栏风格 [英] Android Toolbar style

查看:232
本文介绍了Android的工具栏风格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我添加了一个工具栏,以我的棒棒堂的项目。不过,我有麻烦造型工具栏。我在工具栏标题似乎有一个大胆的字体,但我想它是斜体。任何想法如何实现这一目标?我试着摆弄动作条式,没有运气。

我给自己定一个风格上的工具栏与应用程序:主题=@风格/工具栏我的@款式/工具栏(父ThemeOverlay.AppCompat.ActionBar)是在那里我没有很好的效果玩弄<。 / P>

解决方案

您可以添加的TextView 工具栏里面,例如:

 &LT; android.support.v7.widget.Toolbar的xmlns:机器人=htt​​p://schemas.android.com/apk/re/android
    的xmlns:程序=htt​​p://schemas.android.com/apk/res-auto
    机器人:ID =@ + ID /工具栏
    机器人:layout_height =WRAP_CONTENT
    机器人:layout_width =match_parent
    机器人:=了minHeight?ATTR / actionBarSize
    机器人:后台=&gt;中ATTR / colorPrimary?

    &LT;的TextView
        机器人:ID =@ + ID /标题
        机器人:layout_width =match_parent
        机器人:layout_height =WRAP_CONTENT
        机器人:TEXTSTYLE =斜体/&GT;

&LT; /android.support.v7.widget.Toolbar>
 

I've added a Toolbar to my Lollipop project. However, I'm having trouble styling the Toolbar. My title in the Toolbar appears to have a bold font, but I'd like it to be italic. Any idea how to achieve this? I've tried playing around with the actionbar-style, no luck.

I've set a style on the Toolbar with app:theme="@style/toolbar" and my @style/toolbar (parent ThemeOverlay.AppCompat.ActionBar) is where I'm playing around with no good results.

解决方案

You can add TextView inside Toolbar, for example :

<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/re/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/toolbar"
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:minHeight="?attr/actionBarSize"
    android:background="?attr/colorPrimary" >

    <TextView
        android:id="@+id/title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textStyle="italic" />

</android.support.v7.widget.Toolbar>

这篇关于Android的工具栏风格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆