
getLocationOnScreen方法获取到的是View左上顶点在屏幕中的 绝对位置 (屏幕范围包括状态栏)
获取到的x,y值分别为0,0
我们写的activity或者fragment的布局文件里面最外层的view,去获取他的getLocationInScreen,x为0, y即为状态栏的高度 这也可以是另一种获取状态栏高度的方法
问题一:App 安卓7201280的状态栏、导航栏、主菜单高度分别是50、96、96,那么1080x1920的呢? 7201280的密度与10801920的密度比 乘以高度就好了
问题二:如何修改手机状态栏大小和高度 反编译framework-resapk
2打开res/values/dimensxml文件
3修改如下代码:
250dip
250dip
4第一个是状态栏的高度,250dip是我们现在看到的高度
5第二个是图标的高度
6回编译,替换resourcesarsc到原来的apk里
framework-resapk文件位于/system/framework文件夹中
问题三:android 状态栏高度是多少 可以通过以下方法获取:
public static int getStatusBarHeight(Context context) {
int result = 0;
int resourceId = contextgetResources()getIdentifier(
status_bar_height, dimen, android);
if (resourceId > 0) {
result = contextgetResources()getDimensionPixelSize(resourceId);
}
return result;
}
问题四:android 状态栏高度是多少 可通过下面调用系统方法获取精确的高度:
int resourceId = getResources()getIdentifier(status_bar_height, dimen, android);
获取状态栏高度
int statusBarHeight = getResources()getDimensionPixelSize(resourceId);
问题五:android状态栏是多少dp 可以获取到的。
Rect frame = new Rect();
getWindow()getDecorView()getWindowVisibleDisplayFrame(frame);
int statusBarHeight = frametop;
具体大小我好像记得是20dp不太记得了
问题六:android状态栏高度是多少 一般我觉得45dp就可以了
问题七:android中怎么计算标题栏高度 getWindow()getDecorView()getWindowVisibleDisplayFrame(rect);/取得整个视图部分,注意,如果你要设置标题样式,这个必须出现在标题样式之后,否则会出错
int top = recttop;状态栏的高度,所以rectheight,rectwidth分别是系统的高度的宽度
View v = getWindow()findViewById(WindowID_ANDROID_CONTENT);/获得根视图
int top2 = vgetTop();/状态栏标题栏的总高度,所以标题栏的高度为top2-top
int width = vgetWidth();/视图的宽度,这个宽度好像总是最大的那个
int height = vgetHeight();视图的高度,不包括状态栏和标题栏
如果只想取得屏幕大小,可以用
Display display = getWindowManager()getDefaultDisplay() ;
displaygetWidth();
displaygetHeight();代码见@Overridepublic void onWindowFocusChanged(boolean hasFocus) {
TODO Auto-generated method stub
superonWindowFocusChanged(hasFocus);
Rect frame = new Rect();
getWindow()getDecorView()getWindowVisibleDisplayFrame(frame);
状态栏高度
int statusBarHeight = frametop;
View v = getWindow()findViewById(WindowID_ANDROID_CONTENT);
int contentTop = vgetTop();
statusBarHeight是上面所求的状态栏的高度
int titleBarHeight = contentTop - statusBarHeight;
textView = (TextView) findViewById(RidtextView1);
textViewsetText(标题栏的高度 + IntegertoString(titleBarHeight) +
+ 标题栏高度 + statusBarHeight +
+ 视图的宽度 + vgetWidth()
+
+ 视图的高度(不包含状态栏和标题栏) + vgetHeight());
问题八:安卓480x800状态栏和导航栏高度是多少 分别是12,48 dp @android/style里面有写的
问题九:如何修改 Android 状态栏高度 反编译framework-resapk2打开res/values/dimensxml文件3修改如下代码:250dip250dip4第一个是状态栏的高度,250dip是我们现在看到的高度5第二个是图标的高度6回编译,替换resourcesarsc到原来的apk里
framework-resapk文件位于/system/framework文件夹中
问题十:android 状态栏高度多少25dp 可以通过以下方法获取:
public static int getStatusBarHeight(Context context) {
int result = 0;
int resourceId = contextgetResources()getIdentifier(
status_bar_height, dimen, android");
if (resourceId > 0) {
result = contextgetResources()getDimensionPixelSize(resourceId);
}
return result;
}
在Android开发过程中,有时需要获取View绘制前的高度或者宽度,一种的可能情形是初始化的时候让某个View的Visible = Gone的,当触发某个事件的时候需要它显示并且希望有一些动画效果。
这时候就要获取这个View显示前即绘制前的宽度或者高度。原理很简单,View的绘制过程发生之前,会先执行onMeasure方法。那么就可以利用反射来获取需要的值。下面给出获取高度的代码,宽度同理。
private int getTargetHeight(View v) {
try {
Method m = vgetClass()getDeclaredMethod("onMeasure", intclass,
intclass);
msetAccessible(true);
minvoke(v, MeasureSpecmakeMeasureSpec(
((View) vgetParent())getMeasuredWidth(),
MeasureSpecAT_MOST), MeasureSpecmakeMeasureSpec(0,
MeasureSpecUNSPECIFIED));
} catch (Exception e) {
}
return vgetMeasuredHeight();
}
拿到这个高度之后就可以做想做的动画效果或者是其他的事情了。
以上就是关于android getLocationOnScreen笔记全部的内容,包括:android getLocationOnScreen笔记、安卓状态栏高度是多少、android view怎么获取高度等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)