【发布时间】:2016-04-20 04:42:28
【问题描述】:
我的目标是垂直扩展 Toolbar 并添加类似的信息,如此处所示(特别是我的意思是最后一行带有 car、tram、步行,以及自行车图标和时间):
我使用LinearLayout 在工具栏的 xml 文件中添加了一些内容,事实上,我已经设法拥有一个带有 TextView 的“行”和一个带有 Button 的“行”(如果你需要看截图):
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#CCC">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="48dp"
android:text="Application Title"/>
<Button
android:layout_width="128dp"
android:layout_height="48dp"
android:text="A button"/>
</LinearLayout>
</android.support.v7.widget.Toolbar>
请考虑这个扩展工具栏只会在某些活动期间扩展,它不会永远这样;大多数视图会以简单的形式使用它,即只有应用程序标题和右侧的菜单(我的设计中尚未添加)。
我是在正确的轨道上还是我错过了什么?是否有另一种推荐的方法来获得相同的结果? Google 是这样实现的吗?
【问题讨论】:
标签: android xml android-layout material-design android-toolbar