Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Tip: Calculating Area Covered by Keyboard

DZone's Guide to

Tip: Calculating Area Covered by Keyboard

· Mobile Zone
Free Resource

Discover how to focus on operators for Reactive Programming and how they are essential to react to data in your application.  Brought to you in partnership with Wakanda

As you know if you’ve ever tried it, it’s harder than you’d think it ought to be to figure out just where the keyboard is coming up on the screen. Here’s a tip which looks like a good approach:

Calculating Area Covered by Keyboard

I’ve seen several approaches to this so far, but they often hard code a certain position of the view or sizes. Like assuming that the covered view always reaches towards the bottom of the screen or always has a certain amount of space taken away from it by the status bar, navigation bar and possibly toolbar.

The whole thing gets even more complicated by the fact the the coordinate system of the app’s window is always in portrait even though your app rotates. So is the frame of the keyboard which you can get from an info dictionary in several notifications. I’ll show you the most universally working method I was able to come up with…

Those bars at the bottom are usually the tricky bit, we find. If this actually does handle them properly in just that little bit of code, we’ll be pretty impressed!

Learn how divergent branches can appear in your repository and how to better understand why they are called “branches".  Brought to you in partnership with Wakanda

Topics:

Published at DZone with permission of Alex Curylo, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}