简体   繁体   中英

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. I also tried android:layout_below but i either its not working or I put wrong id (i tried multiple ids). 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.

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

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:

<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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM