如何中心与;左,放大器;右对齐机器人的动作条图标 [英] How to center&left&right align the ActionBar icons in Android

查看:168
本文介绍了如何中心与;左,放大器;右对齐机器人的动作条图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我想对齐一组工具栏的图标,如下面的图片。

hi there I want align a set of icons in toolbar like below picture.

我GOOGLE了一些变化后,我有:

I googled and after some change I have:

mainActivity.xml

mainActivity.xml

...

<include
    android:id="@+id/tool_bar_bottom"
    layout="@layout/tool_bar"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    />
 ....

而在menu_bottom.xml:

And in menu_bottom.xml:

<menu 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" tools:context=".MainActivity">

    <item
        android:id="@+id/action_forward"

        android:title="forward"
        android:orderInCategory="100"
        android:icon="@drawable/ic_action_arrow_forward"
        android:layout_alignParentRight="true"
        app:showAsAction="always"
        ></item>


    <item
        android:id="@+id/action_zoom_in"
        android:orderInCategory="200"
        android:title="zoom in"
        android:icon="@drawable/ic_action_zoom_in"
        app:showAsAction="always"
        ></item>



    <item
        android:id="@+id/action_home"
        android:orderInCategory="300"
        android:title="home"
        android:icon="@drawable/ic_action_home"
        app:showAsAction="always"
        ></item>


    <item
        android:id="@+id/action_refresh"
        android:orderInCategory="400"
        android:title="refresh"
        android:icon="@drawable/ic_action_refresh"
        app:showAsAction="always"
        ></item>

    <item
        android:id="@+id/action_zoom_out"
        android:orderInCategory="500"
        android:title="zoom out"
        android:icon="@drawable/ic_action_zoom_out"
        app:showAsAction="always"
        ></item>

    <item
        android:id="@+id/action_back"
        android:orderInCategory="600"
        android:title="back"
        android:icon="@drawable/ic_action_arrow_back"
        android:layout_alignParentLeft="true"
        app:showAsAction="always"
        ></item>


</menu>

我添加安卓layout_alignParentLeft /右=真正的的左,右也

据图片,我的魔杖右浮动图标,左,右的图标向右。

According the picture,I wand float right icon to left and right icon to right.

此外,我想飘中心的所有其他图标对方身边......

Also I want float center all other icon beside each other...

在code没有任何变化。

The code do not any change.

另外我想补充安卓layout_centerVertical =真正的其他所有图标...

Also I add android:layout_centerVertical = "true" to all other icons...

如何才能正确显示的看法?

how can correct display view?

推荐答案

您可以使用自己的自定义布局在操作栏中,并使用所有属性定位和gravity..etc

you can use your own custom layout in action bar and use all properties for alignment and gravity..etc

<一个href="http://www.techrepublic.com/article/pro-tip-use-a-custom-layout-to-badge-androids-action-bar-menu-items/" rel="nofollow">http://www.techrepublic.com/article/pro-tip-use-a-custom-layout-to-badge-androids-action-bar-menu-items/

<一个href="http://stackoverflow.com/questions/15518414/how-can-i-implement-custom-action-bar-with-custom-buttons-in-android">How我可以实现自定义的操作栏与Android的自定义按钮?

这篇关于如何中心与;左,放大器;右对齐机器人的动作条图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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