守望者--AIR技术交流

标题: 测量软键盘尺寸(Android+IOS) [打印本页]

作者: 破晓    时间: 2015-1-22 10:21
标题: 测量软键盘尺寸(Android+IOS)
Air Native Extension to measure soft keyboard size (Android)

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

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

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

  5. //by default, soft keyboard will push the screen upward, this method can disable it.
  6. 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:

  1. cd /path/to/the/ane/build
  2. mv example.build.config build.config
  3. #edit the build.config file to provide your machine-specific paths
  4. ant
复制代码
AuthorsThis ANE has been written by Lizhao Hou. It belongs to FreshPlanet Inc. and is distributed under theApache Licence, version 2.0.

[attach]564[/attach]

相关链接:
https://github.com/freshplanet/ANE-KeyboardSize
下载







欢迎光临 守望者--AIR技术交流 (http://www.airmyth.com/)