为什么安卓:actionLayout和android:图标在同一时间? [英] Why have android:actionLayout and android:icon at the same time?

查看:537
本文介绍了为什么安卓:actionLayout和android:图标在同一时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读有关忙codeR的Andr​​oid指导的动作条。有一个例子:

 <项目
    机器人:ID =@ + ID /加
    机器人:actionLayout =@布局/加
    机器人:图标=@机器人:可绘制/ ic_menu_add
    机器人:showAsAction =ifRoom
    机器人:标题=@字符串/添加/>

什么是点同时具有的android:actionLayout 安卓图标定义?有什么条件时,图标会显示?

感谢您的帮助了Android的小白


解决方案

  

什么条件时,图标会显示?


我不能排除操作栏将决定没有足够的空间用于 actionLayout 的可能性,但有足够的空间用于操作项,因此这将显示的图标。此外,与ActionBarSherlock,图标显示,即使在Android 2.x设备的溢出,如此反复,如果 actionLayout 将过大,可能会被使用的图标。另外,如果我用 ifRoom |。collapseActionView ,而不是仅仅 ifRoom ,将被使用的图标

话虽这么说:


  • 我的例子实际上不留意此理论的行动项目,它应该出现,做任何事情,如果用户点击它


  • 我猜测在可能的行动条的行为,因为我还没有尝试过任何的实验,迫使操作栏,以决定是否有足够的空间为所有的 actionLayout - 型项目


I am reading about action bars in BusyCoder's Android guide. There is an example:

<item
    android:id="@+id/add"
    android:actionLayout="@layout/add"
    android:icon="@android:drawable/ic_menu_add"
    android:showAsAction="ifRoom"
    android:title="@string/add"/>

What is the point to have both android:actionLayout and android:icon defined? What are the conditions when the icon would show up?

Thanks for helping out Android noob

解决方案

What are the conditions when the icon would show up?

I can't rule out the possibility that the action bar will decide that there is not enough room for the actionLayout, but there is enough room for an action item, which would therefore show the icon. Also, with ActionBarSherlock, the icon is shown even in the overflow on Android 2.x devices, and so again if the actionLayout would be too large, the icon might get used. Also, if I used ifRoom|collapseActionView instead of just ifRoom, the icon would be used.

That being said:

  • My sample does not actually watch for this theoretical action item, should it appear, to do anything if the user clicks on it

  • I am guessing at possible action bar behavior, as I have not tried any experiments to force the action bar to decide whether there is enough room for all actionLayout-configured items

这篇关于为什么安卓:actionLayout和android:图标在同一时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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