So it is not possible to get the real size?
 
Or to get the size of the status bar?
 
In my case I want to make some preprocessing and get somethings prepared 
for future use in the application when the screen rotates.
So, if I am in landscape I get the Heigth.
I also need to know the width of my app when it rotates later to portrait. 
If I have the "real" height I can assume that 
Portrait.width=Landscape.height.
 
So is there no way to get the "real" height? Or get the status bar height?
 
Thanks
Filipe Madureira
 

Segunda-feira, 19 de Novembro de 2012 12:19:38 UTC, Piren escreveu:

> Ahh... i dont think you were getting any different results on 4.1 
> ...Android always reports the height without the bar as long as it is 
> visible.
> Besides, using those values will get your the proper values to work 
> with... why do those calculations while including an area of the screen 
> your cant use? 
>
>
> On Monday, November 19, 2012 1:29:14 PM UTC+2, Makrand wrote:
>>
>> I am trying to get the actual screen width and height of the Nexus 7 
>> running on 4.2.
>>
>> I am doing some runtime calculations based on device width and height to 
>> resize buttons and some UI elements, so it will look proper in all devices. 
>> my code was working great in all SDKs 4.1 and below but not working on 4.2.
>>  
>> I am using following code to get width and height. 
>>
>> Code: 1
>> DisplayMetrics displaymetrics = new DisplayMetrics();
>> getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
>> mWidth = displaymetrics.widthPixels;
>> mHeight = displaymetrics.heightPixels;
>>
>> Code: 2
>> Point size = new Point();
>> WindowManager w = getWindowManager();
>> w.getDefaultDisplay().getSize(size); 
>> mWidth = size.x;
>> mHeight = size.y;
>>
>> I have also tried with undocumented methods 
>> Code: 3
>> Display display = getWindowManager().getDefaultDisplay();
>> Method mGetRawW = Display.class.getMethod("getRawWidth");
>> Method mGetRawH = Display.class.getMethod("getRawHeight");
>> mWidth = (Integer) mGetRawW.invoke(display);
>> mHeight = (Integer) mGetRawH.invoke(display);
>>
>> But none of above is working with Nexus 7 running on 4.2, its always 
>> subtracting status bar height, I am not getting full height. 
>>
>> I have used some methods to calculate status bat height but not getting 
>> proper values, 
>>
>> int statusBarHeight = Math.ceil(25 * 
>> context.getResources().getDisplayMetrics().density);
>>
>> AND
>>
>> Rect rectgle= new Rect();
>> Window window= getWindow();
>> window.getDecorView().getWindowVisibleDisplayFrame(rectgle);
>> int StatusBarHeight= rectgle.top;
>>
>> is there any standard way to get actual device screen height and width?
>>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to