繁体   English   中英

如何在自定义工具栏下放置按钮,edittext等

[英]How to put button, edittext etc below custom toolbar

我创建了一个自定义工具栏。 但是,当我放置诸如imageview,button等之类的东西时,它不会在工具栏下方。 我也尝试了android:layout_below,但我要么无法正常工作,要么我输入了错误的ID(我尝试了多个ID)。 它只是与工具栏混合。

在代码中,imageview正在与工具栏合并,我希望imageview在其下方。

感谢任何回答

码:

<?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包括只是正常的工具栏设置

我得到了答案! 我不得不戴上图像视图标签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.

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