Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
Posts: 27
Registered: ‎08-04-2010
My Device: Not Specified

How can i get the size of the screen when the virtualkeyboard is being shown?

Hi all,

 

 I've met this problem. Before the keyboard is popuped up, the size of the screen is 480*640 which I use Display.getWidth() and Display.getHeight() to get.  After the virtualkeyboard popuped up, the method gave me such size like 480*380. How can i get the actual size of the scrren when the virtualkeyboard is being shown?

 

Thanks.

Developer
Posts: 243
Registered: ‎07-22-2011
My Device: BlackBerry Z10
My Carrier: AirTel

Re: How can i get the size of the screen when the virtualkeyboard is being shown?

Hi,

 

For that case we can use getScreen.getWidth() and getScreen.getHeight().

 

Regards,

Lakshman K

----------------------------------------------------------
Feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.

Developer
Posts: 228
Registered: ‎10-01-2011
My Device: Passport

Re: How can i get the size of the screen when the virtualkeyboard is being shown?

Did you try this.getScreen().getPreferredHeight() ?

Contributor
Posts: 27
Registered: ‎08-04-2010
My Device: Not Specified

Re: How can i get the size of the screen when the virtualkeyboard is being shown?

getScreen().getPreferredWidth()  and  getScreen().getPreferredHeight()  showed me 0 and 0;

 

getScreen().getWidth() and getScreen().getHeight() showed me the same result as Display.getWidth() and Display.getHeight();

 

So the problem is still here.

Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How can i get the size of the screen when the virtualkeyboard is being shown?

the value is the actual height when the keyboard is shown, as the screen is reduced in its drawing area.
you can check for the virtual keyboard to be visible, but i don't know of a method to check the "real" height short of taking a screenshot and measuring the result.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 228
Registered: ‎10-01-2011
My Device: Passport

Re: How can i get the size of the screen when the virtualkeyboard is being shown?

I see you can't  even get the height of the keyboard so you could calculate the size.   I think you need to get the size before the keyboard is shown and store it.  Or an alternative is to hide the keyboard get the size then unhide it, that's  a bit of a hack though.

 

------------------------------------------------------------------------
Please press the LIKE button on the right if I helped you.
Please press the SOLVED if this solved your problem