Ton*_*y D 6 android android-actionbar
我知道有很多ActionBar问题,但它们似乎没有解决我的问题.我可以在我的模拟器中吐出ActionBar,但是当我在我的设备上运行我的程序(Nexus 7肖像模式)时,ActionBar将不会分裂.所有图标都堆积在顶部,甚至我的标签创建了一个下拉列表.我试图通过使菜单项名称非常长来强制解决问题,我确实将它们设置为:android:showAsAction ="always | withText".只是为了确定,我已经采用了示例代码,在模拟器上运行它看到它工作,然后把它放在我的设备上无济于事.这是我的清单:
<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>
Run Code Online (Sandbox Code Playgroud)
我已经搜索过网络,但无法找到解决方案.任何帮助表示赞赏.
我知道这个问题已经很老了,但是我找到了一种方法来强制操作栏到Nexus 7(以及可能的其他设备)上的按钮,我想我会分享我的解决方案:
将此代码放在您的活动中:
/**
* {@inheritDoc}
*/
@Override
public Resources getResources() {
return new ResourceFix(super.getResources());
}
private class ResourceFix extends Resources {
private int targetId = 0;
ResourceFix(Resources resources) {
super(resources.getAssets(), resources.getDisplayMetrics(), resources.getConfiguration());
targetId = Resources.getSystem().getIdentifier("split_action_bar_is_narrow", "bool", "android");
}
/**
* {@inheritDoc}
*/
@Override
public boolean getBoolean(int id) throws Resources.NotFoundException {
return targetId == id || super.getBoolean(id);
}
}
Run Code Online (Sandbox Code Playgroud)
这将强制内部"split_action_bar_is_narrow"值为true.它可能不是最好的方法,但它似乎是我找到的唯一方法.
| 归档时间: |
|
| 查看次数: |
3224 次 |
| 最近记录: |