freshplanet / ANE-KeyboardSize

Air Native Extension (Android) for measuring soft keyboard size
Apache License 2.0
31 stars 15 forks source link

Air Native Extension to measure soft keyboard size (Android)

This is an Air native extension that measures the soft keyboard size, because the actionscript method flash.display.Stage.softKeyboardRect():Rectangle doesn't return a correct value in Android.

Usage

//get the height of the keyboard
var keyboardHeight:Number = MeasureKeyboard.getInstance().getKeyboardHeight() as Number;

//get the y (vertical position) of the keyboard
var keyboardY:Number = MeasureKeyboard.getInstance().getKeyboardY() as Number;

//by default, soft keyboard will push the screen upward, this method can disable it.
MeasureKeyboard.getInstance().setKeyboardAdjustNothing();

Notes:

Installation

The ANE binary (KeyboardSize.ane) is located in the bin folder. You should add it to your application project's Build Path and make sure to package it with your app.

Build script

Should you need to edit the extension source code and/or recompile it, you will find an ant build script (build.xml) in the build folder:

cd /path/to/the/ane/build
mv example.build.config build.config
#edit the build.config file to provide your machine-specific paths
ant

Authors

This ANE has been written by Lizhao Hou. It belongs to FreshPlanet Inc. and is distributed under the Apache Licence, version 2.0.