我正在尝试实现如下扩展的应用栏:
但是我不知道该怎么做,我已经寻找了一段时间,但是还没有遇到任何解释如何做的事情,所以现在我在这里。
我当前工具栏的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"
>
但是我不知道该如何继续下去,如果有人可以举一个例子,向我指出正确的方向,或者提供一个很棒的教程。
提前致谢!
最佳答案
我不知道这是否是正确的方法,因为我找不到任何有关如何正确实现的示例或解释,但目前我已使用以下代码修复了它:
<?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
左上角没有“返回”箭头,这是另一次
如果有人可以确认这是正确的方法或提供正确的方法,那就太好了!
编辑:激活工具栏中的向上箭头以返回到父活动会自动为linearlayout中的textinputs提供左边界,因此您可以删除72dp左边界