[英]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.