【问题标题】:How to add widgets to toolbar and increase its height如何将小部件添加到工具栏并增加其高度
【发布时间】:2015-01-22 08:33:26
【问题描述】:

我希望在我的活动中向工具栏添加几个 EditText,并根据 Material 设计规范增加其高度,如下图所示:

我如何实现这一点,即如何将普通小部件添加到工具栏并增加它的高度?

谢谢!

【问题讨论】:

    标签: android material-design android-toolbar


    【解决方案1】:

    你不会相信,但它是如此简单:

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.v7.widget.Toolbar 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="250dp"            // Height of toolbar 
    android:background="@color/anycolor">
    
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint=""/>
    
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint=""/>   
    
    //Add as many widgets as you want
    
    </android.support.v7.widget.Toolbar>
    

    【讨论】:

    • 你是对的。没想到这么简单!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多