Android的动作条将不分裂设备将不、动作、设备、Android

2023-09-12 23:39:38 作者:哼!

我知道已经有很多动作条问题,但他们似乎并没有解决我的问题。我能吐的动作条在我的模拟器,但是当我在我的设备(的Nexus 7肖像模式)上运行我的程序的动作条将不会分裂。所有图标顶部堆起来,连我的标签创建一个下拉列表中。我试图通过菜单项的名称很长,迫使这一问题,我将其设置为:机器人:showAsAction =永远| withText。为了保险起见,我已采​​取抽样code,跑了就看到它的工作,然后把它放在我的设备上没有用的模拟器。这里是我的清单:

I know there have been many ActionBar questions but they don't seem to address my problem. I am able to spit the ActionBar in my emulator, but when I run my program on my device (Nexus 7 portrait mode) the ActionBar will not split. All the icons 'pile up' on top, even my tabs create a drop down list. I have tried to force the issue by making the menu items names extremely long and I do have them set to: android:showAsAction="always|withText". Just to be sure, I have taken sample code, ran it on the emulator seen it work and then put it on my device to no avail. Here's my manifest:

<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="15" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/MyTheme">
    <activity
        android:name=".MainActivity"
        android:uiOptions="splitActionBarWhenNarrow"
        android:label="@string/title_activity_main">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

我已走遍了网络,但无法找到一个解决方案。任何帮助是AP preciated。

I have scoured the web but cannot find a solution. Any help is appreciated.

推荐答案

据this SO项,在ActionBar仅当可用宽度小于480dp分裂。据谷歌的戴安娜Hackborn这篇文章然而,Nexus 7保护的纵向宽度为600dp 。所以这就是原因没有分裂。

According to this SO item, the ActionBar is only splitted when the available width is less than 480dp. According to this article of Google's Dianne Hackborn however, the portrait width of the Nexus 7 is 600dp. So that's the reason there's no splitting.

我同意你的看法,即分裂应取决于可用空间和项目之间的关系表现出来,而不是单独的可用空间。

I agree with you, that the splitting should depend on the relation between available space and items to be shown, not on the available space alone.