建立在Android的一个底部的工具栏的最佳方法。 [英] Best way to create a bottom toolbar in android.

查看:190
本文介绍了建立在Android的一个底部的工具栏的最佳方法。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

寻找一个好的方法来实现类似的工具栏。我应该使用图像按钮??

解决方案

 < android.support.v7.widget.Toolbar的xmlns:机器人=htt​​p://schemas.android。 COM / APK / RES /安卓
的xmlns:程序=htt​​p://schemas.android.com/apk/res-auto
机器人:ID =@ + ID / actionbarT
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:背景=@可绘制/ thebackgroundimageyouwant
机器人:=了minHeight?ATTR / actionBarSize
应用程序:主题=@风格/ Base.Theme.AppCompat.CompactMenu>

    <的LinearLayout
        机器人:ID =@ + ID / toolbarmenucontainer
        机器人:layout_width =match_parent
        机器人:weightSum =3
        机器人:layout_height =match_parent
        机器人:方向=横向>

        <的ImageButton
            机器人:layout_width =0dp
            机器人:layout_height =match_parent
            机器人:背景=@可绘制/ preferedbackground
            机器人:可点击=真
            机器人:scaleType =fitXY
            机器人:体重=1
            机器人:SRC =@可绘制/ preferredimage/>

         <的ImageButton
            机器人:layout_width =0dp
            机器人:layout_height =match_parent
            机器人:背景=@可绘制/ preferedbackground
            机器人:可点击=真
            机器人:scaleType =fitXY
            机器人:体重=1
            机器人:SRC =@可绘制/ preferredimage/>

        <的ImageButton
            机器人:layout_width =0dp
            机器人:layout_height =match_parent
            机器人:背景=@可绘制/ preferedbackground
            机器人:可点击=真
            机器人:scaleType =fitXY
            机器人:体重=1
            机器人:SRC =@可绘制/ preferredimage/>

    < / LinearLayout中>

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

这个想法是,他们将制定出水平就像一个你想要的,然后也没有做 ToolBar.setTitle()或setnagivati​​on上的工具栏你也不必optionsMenu添加到它。所以这将是裸像你想要的。

尝试一下,看看它是否符合您的要求,请记住背景和图像SRC添加到的ImageButton 取值

Looking for a good approach to achieve a similar toolbar. Should I use image buttons ??

解决方案

<android.support.v7.widget.Toolbar  xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/actionbarT"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/thebackgroundimageyouwant"
android:minHeight="?attr/actionBarSize"
app:theme="@style/Base.Theme.AppCompat.CompactMenu" >

    <LinearLayout
        android:id="@+id/toolbarmenucontainer"
        android:layout_width="match_parent"
        android:weightSum="3"
        android:layout_height="match_parent"
        android:orientation="horizontal" >

        <ImageButton
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:background="@drawable/preferedbackground"
            android:clickable="true"
            android:scaleType="fitXY"
            android:weight = "1"
            android:src="@drawable/preferredimage" />

         <ImageButton
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:background="@drawable/preferedbackground"
            android:clickable="true"
            android:scaleType="fitXY"
            android:weight = "1"
            android:src="@drawable/preferredimage" />

        <ImageButton
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:background="@drawable/preferedbackground"
            android:clickable="true"
            android:scaleType="fitXY"
            android:weight = "1"
            android:src="@drawable/preferredimage" />

    </LinearLayout>

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

the idea is they will lay out horizontally like the one you want, also then do not do ToolBar.setTitle() or setnagivation on the ToolBar also you don't have to add optionsMenu to it. so it will be bare like the one you want.

try it and see if it fits your requirement, remember to add the background and image src to the ImageButtons

这篇关于建立在Android的一个底部的工具栏的最佳方法。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆