【问题标题】:Extended app bar?扩展应用栏?
【发布时间】:2016-07-17 09:28:02
【问题描述】:

我正在尝试实现这样的扩展应用栏:

但我不知道该怎么做,我一直在寻找一段时间,但没有找到解释如何做到这一点的东西,所以现在我在这里。

我当前工具栏的 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"
>

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

提前致谢!

【问题讨论】:

    标签: android android-actionbar toolbar appbar


    【解决方案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

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

    如果有人可以确认这是正确的方法或提供正确的方法,那就太好了!

    编辑:激活工具栏中的向上箭头以返回父活动自动为线性布局中的文本输入提供左边距,因此您可以删除 72dp 左边距

    【讨论】:

      猜你喜欢
      • 2020-05-31
      • 1970-01-01
      • 2020-12-09
      • 2016-04-01
      • 2011-04-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多