项目冠军的画像,SHOW_AS_ACTION_WITH_TEXT不显示 [英] Item title not displayed in portrait with SHOW_AS_ACTION_WITH_TEXT
问题描述
在我的活动,我有一个动作模式,其中有一个标题和图标的单个项目。
我要显示标题和图标,所以我用SHOW_AS_ACTION_WITH_TEXT和SHOW_AS_ACTION_ALWAYS标志。
在横向方向,它的罚款。我有标题+图标。 但是纵向只有图标显示(虽然有很多的自由空间)。有谁知道我可以做些什么来解决这个问题?
请注意,如果我删除图标标题正确显示。
下面是我的示例code:
公共类TestActivity延伸活动{
@覆盖
保护无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
startActionMode(新的回调(){
@覆盖
公共布尔onCreateActionMode(ActionMode模式,菜单菜单){
menu.add(项目1)的setIcon(R.drawable.ic_launcher).setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT | MenuItem.SHOW_AS_ACTION_ALWAYS)。
返回true;
}
@覆盖
在prepareActionMode(ActionMode模式,菜单菜单){返回false公共布尔; }
@覆盖
公共无效onDestroyActionMode(ActionMode模式){}
@覆盖
公共布尔onActionItemClicked(ActionMode模式,菜单项项){返回false; }
});
}
}
有谁知道我可以做些什么来解决这个问题?
我怀疑,你可以。 永远和文字的要求,不是命令。该框架不总是尊敬他们的任何。
In my activity, I have an action mode with a single item which has a title and an icon.
I want both the title and the icon to be displayed, so I use SHOW_AS_ACTION_WITH_TEXT and SHOW_AS_ACTION_ALWAYS flags.
In landscape orientation, it's fine. I have title + icon. But in portrait orientation only the icon is displayed (though there's a lot of free space). Does anyone know what I could do to fix it ?
Note that the title is correctly displayed if I remove the icon.
Here is my sample code:
public class TestActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
startActionMode(new Callback() {
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
menu.add("Item 1").setIcon(R.drawable.ic_launcher).setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT | MenuItem.SHOW_AS_ACTION_ALWAYS);
return true;
}
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; }
@Override
public void onDestroyActionMode(ActionMode mode) { }
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) { return false; }
});
}
}
Does anyone know what I could do to fix it ?
I doubt that you can. "Always" and "with text" are requests, not commands. The framework does not always honor either of them.
这篇关于项目冠军的画像,SHOW_AS_ACTION_WITH_TEXT不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!