平板界面状态栏按下menu键显示不出,无响应
来源:互联网 发布:天谕玉虚捏脸数据图 编辑:程序博客网 时间:2024/06/01 09:08
1.问题描述:
在4.1的系统下,调试机器是768*1024的
默认: 在launcher 界面时状态栏显示menu键,menu键可以显示,但是按下menu键时却没有相应界面弹出,
但是原来的机器:1024*600的就没有任何问题
1)查找原因:
launcher代码问题,通过不同的机器对比同样的代码,证明代码没有问题
资源布局问题:强行走1024*600的布局,证明布局没有问题
唯一区别代码尺寸不同,最后只能追查menu键按下的处理过程,最终确认原因。
2)确认问题原因:
menu键按下处理的关键:
文件:
PhoneWindow.java (frameworks\base\policy\src\com\android\internal\policy\impl)
按键按下后会走到一下的两个文件:
public final boolean onKeyDownPanel(int featureId, KeyEvent event) {
}
public final void onKeyUpPanel(int featureId, KeyEvent event) {
...
openPanel(st, event);
...
}
private void openPanel(PanelFeatureState st, KeyEvent event) {
// System.out.println("Open panel: isOpen=" + st.isOpen);
// Already open, return
if (st.isOpen || isDestroyed()) {
return;
}
// Don't open an options panel for honeycomb apps on xlarge devices.
// (The app should be using an action bar for menu items.)
if (st.featureId == FEATURE_OPTIONS_PANEL) {
Context context = getContext();
Configuration config = context.getResources().getConfiguration();
boolean isXLarge = (config.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) ==
Configuration.SCREENLAYOUT_SIZE_XLARGE;
boolean isHoneycombApp = context.getApplicationInfo().targetSdkVersion >=
android.os.Build.VERSION_CODES.HONEYCOMB;
if (isXLarge && isHoneycombApp) {
return;
}//这里就是问题的原因
}
...
}
3)//问题分析,条件有两个
isXLarge 和 isHoneycombApp
isXLarge 为真:
boolean isXLarge = (config.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) ==
Configuration.SCREENLAYOUT_SIZE_XLARGE;
分析:文件:WindowManagerService.java (frameworks\base\services\java\com\android\server\wm)
private int reduceConfigLayout(int curLayout, int rotation, float density, int dw, int dh) {
...
// configuration. DO NOT CHANGE!
if (longSize < 470) {
// This is shorter than an HVGA normal density screen (which
// is 480 pixels on its long side).
screenLayoutSize = Configuration.SCREENLAYOUT_SIZE_SMALL;
screenLayoutLong = false;
screenLayoutCompatNeeded = false;
} else {
// What size is this screen screen?
if (longSize >= 960 && shortSize >= 720) {
// 1.5xVGA or larger screens at medium density are the point
// at which we consider it to be an extra large screen.
screenLayoutSize = Configuration.SCREENLAYOUT_SIZE_XLARGE;//系统走的是这里,原因
} else if (longSize >= 640 && shortSize >= 480) {
// VGA or larger screens at medium density are the point
// at which we consider it to be a large screen.
screenLayoutSize = Configuration.SCREENLAYOUT_SIZE_LARGE;
} else {
screenLayoutSize = Configuration.SCREENLAYOUT_SIZE_NORMAL;
}
...
}
4)解决方法:在函数中屏蔽掉,问题解决,按menu键后弹出选项:
private void openPanel(PanelFeatureState st, KeyEvent event) {
if (isXLarge && isHoneycombApp) {
;//return;//屏蔽掉
}//这里就是问题的原因
}
在4.1的系统下,调试机器是768*1024的
默认: 在launcher 界面时状态栏显示menu键,menu键可以显示,但是按下menu键时却没有相应界面弹出,
但是原来的机器:1024*600的就没有任何问题
1)查找原因:
launcher代码问题,通过不同的机器对比同样的代码,证明代码没有问题
资源布局问题:强行走1024*600的布局,证明布局没有问题
唯一区别代码尺寸不同,最后只能追查menu键按下的处理过程,最终确认原因。
2)确认问题原因:
menu键按下处理的关键:
文件:
PhoneWindow.java (frameworks\base\policy\src\com\android\internal\policy\impl)
按键按下后会走到一下的两个文件:
public final boolean onKeyDownPanel(int featureId, KeyEvent event) {
}
public final void onKeyUpPanel(int featureId, KeyEvent event) {
...
openPanel(st, event);
...
}
private void openPanel(PanelFeatureState st, KeyEvent event) {
// System.out.println("Open panel: isOpen=" + st.isOpen);
// Already open, return
if (st.isOpen || isDestroyed()) {
return;
}
// Don't open an options panel for honeycomb apps on xlarge devices.
// (The app should be using an action bar for menu items.)
if (st.featureId == FEATURE_OPTIONS_PANEL) {
Context context = getContext();
Configuration config = context.getResources().getConfiguration();
boolean isXLarge = (config.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) ==
Configuration.SCREENLAYOUT_SIZE_XLARGE;
boolean isHoneycombApp = context.getApplicationInfo().targetSdkVersion >=
android.os.Build.VERSION_CODES.HONEYCOMB;
if (isXLarge && isHoneycombApp) {
return;
}//这里就是问题的原因
}
...
}
3)//问题分析,条件有两个
isXLarge 和 isHoneycombApp
isXLarge 为真:
boolean isXLarge = (config.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) ==
Configuration.SCREENLAYOUT_SIZE_XLARGE;
分析:文件:WindowManagerService.java (frameworks\base\services\java\com\android\server\wm)
private int reduceConfigLayout(int curLayout, int rotation, float density, int dw, int dh) {
...
// configuration. DO NOT CHANGE!
if (longSize < 470) {
// This is shorter than an HVGA normal density screen (which
// is 480 pixels on its long side).
screenLayoutSize = Configuration.SCREENLAYOUT_SIZE_SMALL;
screenLayoutLong = false;
screenLayoutCompatNeeded = false;
} else {
// What size is this screen screen?
if (longSize >= 960 && shortSize >= 720) {
// 1.5xVGA or larger screens at medium density are the point
// at which we consider it to be an extra large screen.
screenLayoutSize = Configuration.SCREENLAYOUT_SIZE_XLARGE;//系统走的是这里,原因
} else if (longSize >= 640 && shortSize >= 480) {
// VGA or larger screens at medium density are the point
// at which we consider it to be a large screen.
screenLayoutSize = Configuration.SCREENLAYOUT_SIZE_LARGE;
} else {
screenLayoutSize = Configuration.SCREENLAYOUT_SIZE_NORMAL;
}
...
}
4)解决方法:在函数中屏蔽掉,问题解决,按menu键后弹出选项:
private void openPanel(PanelFeatureState st, KeyEvent event) {
if (isXLarge && isHoneycombApp) {
;//return;//屏蔽掉
}//这里就是问题的原因
}
- 平板界面状态栏按下menu键显示不出,无响应
- android 界面 状态栏按下 menu键 显示不出,无响应
- 平板导航栏Menu键,显示
- iOS在某个界面不显示状态栏
- 为什么状态栏不显示鼠标按下的键和位置?
- 如何在用户停止操作一段时间后隐藏界面上的某些东东,比如遥控器按出的menu,一段时间不按遥控器就让menu消失
- 状态栏显示不出来
- 状态栏第一次不显示
- 不显示状态栏
- Android中添加Options Menu,按MENU键无反应
- Android中添加Options Menu,按MENU键无反应
- android 6.0 home界面按menu键打开“管理应用”,应用列表刷新不出来
- android4.0以后的系统,按menu键显示的菜单中无icon的解决方法
- android 不显示menu 按键
- ActionbarActivity上不显示menu
- Toolbar中Menu不显示
- Menu中icon不显示
- 解决:menu/ActionBar不显示
- SMSLib开发指南
- 支付宝接口程序、文档及解读(ASP.NET)
- .net解析带命名空间的xml写法
- SSH的作用
- 两船载物问题
- 平板界面状态栏按下menu键显示不出,无响应
- 企业视频方案
- Autson Skitter Slideshow
- set view margin in code dynamically
- Wireshark抓包工具使用教程以及常用抓包规则
- VC6 串口发送接收注意事项
- Spring的作用
- 暑假编程训练----A:乘法口诀
- C++的异常处理