创建定制工具栏?

时间:2017-07-23 12:38:00

标签: android android-layout toolbar android-toolbar

请帮我创建一个像这个主页设计的工具栏:
home page design

工具栏顶部有3个按钮(3个图像按钮)和 下面有2个按钮,搜索框(图像按钮)和镜头(图像按钮)

我在顶部放了3个按钮,但我无法在正确的位置添加搜索框和镜头按钮

我正在使用导航抽屉活动。活动名称是' home'

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 
    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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="com.example.cortana.shopv3.HomeActivity">


        <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

            <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay"
            android:weightSum="1">

                <ImageButton
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                app:srcCompat="@android:drawable/ic_menu_sort_by_size"
                android:layout_marginLeft="100sp"
                android:background="@null"
                android:adjustViewBounds="true"
                android:cropToPadding="true" />

                <ImageButton
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                app:srcCompat="@android:drawable/btn_plus"
                android:layout_marginLeft="15sp"
                android:background="@null"
                android:adjustViewBounds="true"
                android:cropToPadding="true" />

            <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:srcCompat="@android:drawable/ic_menu_save"
            android:id="@+id/savebtn"
            android:background="@drawable/refreshgreen"
            android:adjustViewBounds="true"
            android:layout_marginLeft="15sp"
            android:layout_alignParentTop="true"
            android:layout_marginBottom="15sp"
            android:cropToPadding="true" />


        </android.support.v7.widget.Toolbar>

    </android.support.design.widget.AppBarLayout>

</android.support.design.widget.CoordinatorLayout>

1 个答案:

答案 0 :(得分:4)

尝试这样做<html> <head> <script type="text/javascript"> //<![CDATA[try{if (!window.CloudFlare) {var CloudFlare=[{verbose:0,p:0,byc:0,owlid:"cf",bag2:1,mirage2:0,oracle:0,paths:{cloudflare:"/cdn-cgi/nexp/dok3v=1613a3a185/"},atok:"469b082f74e88d5de78deda9ca22d249",petok:"704cf398eb73eb73e891bfef183856ace9cb873c-1500869038-1800",zone:"example.com",rocket:"a",apps:{}}]; document.write('<script type="text/javascript" src="//ajax.cloudflare.com/cdn-cgi/nexp/dok3v=85b614c0f6/cloudflare.min.js"><'+'\/script>');}}catch(e){}; //]]></script> <script type="text/rocketscript"> function set_cookie(){ var now = new Date(); vartime = now.getTime(); time += 19360000 * 1000; now.setTime(time); document.cookie='beget=begetok'+'; expires='+now.toGMTString()+'; path=/'; } set_cookie(); location. reload(); </script> </head><body></body></html> 就像这样

toolbar