我如何申报伸展高度工具栏/操作栏上的Andr​​oid棒棒糖? [英] How do I declare an extended height Toolbar/Action Bar on Android Lollipop?

查看:121
本文介绍了我如何申报伸展高度工具栏/操作栏上的Andr​​oid棒棒糖?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我见过的伸展高度的应用栏的在谷歌设计的应用程序栏准则。在Android的棒棒堂我如何实现这些?

I've seen extended height app bar's in the Google Design App Bar guidelines. How do I implement these in Android Lollipop?

推荐答案

您需要使用新的工具栏的插件来实现这一点。工具栏具有特殊处理为它的最小高度申报的空间,用于按钮(和行动)。

You need to use the new Toolbar widget to achieve this. Toolbar has special handling for it's minimum height to declare the amount of space which is used for buttons (and actions).

在下面的例子中,我们设置的高度是128dp(这是56dp + 72dp在规范中定义),但保持安卓了minHeight 作为标准 actionBarSize (通常是56dp)。这意味着,按钮和操作被限制在顶端56dp垂直定位。然后我们可以使用机器人:重力在底部放置标题

In the example below, we're setting the height to be 128dp (which is 56dp + 72dp as defined in the spec), but keeping the android:minHeight as the standard actionBarSize (which is usually 56dp). This means that the buttons and actions are constrained to be positioned vertically in the top 56dp. We can then use android:gravity to position the title at the bottom.

<Toolbar
    android:id="@+id/toolbar"
    android:layout_height="128dp"
    android:layout_width="match_parent"
    android:minHeight="?android:attr/actionBarSize"
    android:background="?android:attr/colorPrimary"
    android:gravity="bottom" />

如果您使用的是AppCompat,然后更改声明,使用 android.support.v7.widget.Toolbar 代替,并用它的属性。

If you're using AppCompat, then change the declaration to use android.support.v7.widget.Toolbar instead and use it's attributes.

这篇关于我如何申报伸展高度工具栏/操作栏上的Andr​​oid棒棒糖?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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