课程/Android/移动开发
360加速球核心效果实现
-
-
慕先生0560154
2016-08-23
- 获取状态栏的高:
利用反射的方式
这里还有另外一种方法,大家都知道Android的所有资源都会有惟一标识在R类中作为引用。我们也可以通过反射获取R类的实例域,代码如下
/**
* 获得状态栏的高度
*
* @param context
* @return
*/
public static int getStatusHeight(Context context) {
int statusHeight = -1;
try {
Class<!--?--> clazz = Class.forName("com.android.internal.R$dimen");
Object object = clazz.newInstance();
int height = Integer.parseInt(clazz.getField("status_bar_height")
.get(object).toString());
statusHeight = context.getResources().getDimensionPixelSize(height);
} catch (Exception e) {
e.printStackTrace();
}
return statusHeight;
}
-
0赞 · 0采集
-
-
慕先生0560154
2016-08-23
- 底部菜单的显示
-
截图
0赞 · 0采集