[英]How to put button, edittext etc below custom toolbar
I have created a custom toolbar. 我创建了一个自定义工具栏。 But when I put things like imageview, button etc it wont be below toolbar.
但是,当我放置诸如imageview,button等之类的东西时,它不会在工具栏下方。 I also tried android:layout_below but i either its not working or I put wrong id (i tried multiple ids).
我也尝试了android:layout_below,但我要么无法正常工作,要么我输入了错误的ID(我尝试了多个ID)。 Its just mixing with the toolbar.
它只是与工具栏混合。
In the code the imageview is merging with the toolbar and i want the imageview to be below it. 在代码中,imageview正在与工具栏合并,我希望imageview在其下方。
Thanks for anyone who answers 感谢任何回答
code: 码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
<ImageView
android:id="@+id/icon"
android:layout_below="@id/toolbar"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="@drawable/shoppingcart"
android:layout_width="100dp"
android:layout_height="100dp"
/>
<android.support.design.widget.TextInputLayout
android:layout_below="@+id/icon"
android:id="@+id/forgot_input_email"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/forgot_email"
android:hint="Enter groceries"
android:inputType="textCapWords"
android:maxLines="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</android.support.design.widget.TextInputLayout>
Ps include is just the normal toolbar settings PS包括只是正常的工具栏设置
I got my answer! 我得到了答案! I had to put on image view tag android:layout_marginTop="?attr/actionBarSize", it just do it below the height of the toolbar/actionbar Like that:
我不得不戴上图像视图标签android:layout_marginTop =“?attr / actionBarSize”,它只是在工具栏/ actionbar的高度以下进行操作,就像这样:
<ImageView
android:layout_marginTop="?attr/actionBarSize"
android:id="@+id/icon"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="@drawable/shoppingcart"
android:layout_width="100dp"
android:layout_height="100dp"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.