扩展应用栏?

时间:2016-03-29 17:15:13

标签: android android-actionbar toolbar appbar

我试图像这样实现扩展的应用栏:

screenshot

但是我不知道该怎么做,我现在已经找了一段时间但是却没有找到解释如何做的事情所以我现在就在这里。

我当前工具栏的XML代码是

<?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:id="@+id/toolbar_add_activity"
android:layout_width="match_parent"
android:layout_height="232dp"
android:minHeight="56dp"
android:background="@color/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
>

但我不知道如何继续,如果有人可以举一个例子,请指出我正确的方向或提供一个很棒的教程。

提前致谢!

1 个答案:

答案 0 :(得分: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:id="@+id/toolbar_add_activity"
android:layout_width="match_parent"
android:layout_height="232dp"
android:minHeight="56dp"
android:background="@color/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">


<LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="56dp"
    android:layout_marginLeft="72dp">

    <android.support.design.widget.TextInputLayout
        android:id="@+id/input_title"
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:layout_marginBottom="8dp">
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/editText8"
        android:hint="Title" />
</android.support.design.widget.TextInputLayout>

<android.support.design.widget.TextInputLayout
    android:id="@+id/input_description"
    android:layout_width="match_parent"
    android:layout_height="72dp"
    android:layout_marginBottom="16dp">
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/editText9"
        android:hint="Description" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</android.support.v7.widget.Toolbar>

它看起来像这样(由于没有足够的代表,我无法嵌入图片):image

左上角没有“返回”箭头,这是另一次

如果有人能够确认这是正确的方法,或者提供正确的方法,那就太棒了!

编辑:激活工具栏中的向上箭头以自动返回父活动,在左边距的线性布局中给出textinput,这样就可以删除72dp的左边距