【问题标题】:Extend Toolbar vertically like Google Maps application像谷歌地图应用程序一样垂直扩展工具栏
【发布时间】:2016-04-20 04:42:28
【问题描述】:

我的目标是垂直扩展 Toolbar 并添加类似的信息,如此处所示(特别是我的意思是最后一行带有 cartram步行,以及自行车图标和时间):

我使用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


    【解决方案1】:

    看到这个帖子:Android TabLayout Android Design 尤其是问题中指向Android Developers Blog 的链接。您想为带有汽车、自行车等的选项卡和扩展工具栏使用 Tablayout。两者都在博文中进行了描述。

    【讨论】:

    • 您的意思是折叠工具栏,没错,就是它!其他人将此作为评论提及,但您已发布答案,所以我会接受。
    猜你喜欢
    • 1970-01-01
    • 2014-07-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-21
    • 1970-01-01
    • 2015-12-10
    相关资源
    最近更新 更多