farhad.kargaran
farhad.kargaran

Reputation: 2373

get android keyboard height even without showing keyboard

I am developing an IM app. I want to set my sticker panel's height exactly like keyboard height.

I can calculate height of keyboard if it appears in my activity using Viewtree Observer and global layout listener but maybe user open sticker panel before kerboard so I have to set sticker panel's height exactly like keyboard.

So I want to have keyboard height even without showing keyboard like what Viber or Telegram does.

Any Idea?

Upvotes: 1

Views: 904

Answers (2)

aravindkanna
aravindkanna

Reputation: 683

Before the start of your app, I guess user should enter some kind of text be it username or number. So there get the height of keyboard and store it in shared preferences. Use height in preferences whenever you want. Also update the preferences when the keyboard height changes and use different variable to store landscape and portrait heights.

Or you may intentionally show and hide the keyboard for the first time and then store the keyboard height in preferences. Then you can use it wherever you want.

Upvotes: 2

Alexander Suslov
Alexander Suslov

Reputation: 76

If you have activity with EditText which appears before your chat activity (registration screen for example), you can save keyboard height in preferences and use it later on the chat activity.

Upvotes: 1

Related Questions