public class KeyboardUtil extends Object
getValidPanelHeight(Context).
Adapt the panel height with the keyboard height just relate
attach(Activity, IPanelHeightTarget).KeyBoardSharedPreferences| Modifier and Type | Class and Description |
|---|---|
static interface |
KeyboardUtil.OnKeyboardShowingListener
The interface is used to listen the keyboard showing state.
|
| Constructor and Description |
|---|
KeyboardUtil() |
| Modifier and Type | Method and Description |
|---|---|
static ViewTreeObserver.OnGlobalLayoutListener |
attach(Activity activity,
IPanelHeightTarget target) |
static ViewTreeObserver.OnGlobalLayoutListener |
attach(Activity activity,
IPanelHeightTarget target,
KeyboardUtil.OnKeyboardShowingListener lis)
Recommend invoked by
Activity.onCreate(Bundle)
For align the height of the keyboard to target as much as possible. |
static void |
detach(Activity activity,
ViewTreeObserver.OnGlobalLayoutListener l)
Remove the OnGlobalLayoutListener from the activity root view
|
static int |
getKeyboardHeight(Context context) |
static int |
getMaxPanelHeight(Resources res) |
static int |
getMinKeyboardHeight(Context context) |
static int |
getMinPanelHeight(Resources res) |
static int |
getValidPanelHeight(Context context) |
static void |
hideKeyboard(View view) |
static void |
showKeyboard(View view) |
public static void showKeyboard(View view)
public static void hideKeyboard(View view)
public static int getKeyboardHeight(Context context)
context - the keyboard height is stored by shared-preferences, so need context.getValidPanelHeight(Context),
Handle and refresh the keyboard height by {@link #attach(Activity, IPanelHeightTarget)}.public static int getValidPanelHeight(Context context)
context - the keyboard height is stored by shared-preferences, so need context.getMaxPanelHeight(Resources),
getMinPanelHeight(Resources),
getKeyboardHeight(Context),
The keyboard height may be too short or too height. we intercept the keyboard height in
[{@link #getMinPanelHeight(Resources)}, {@link #getMaxPanelHeight(Resources)}].public static int getMaxPanelHeight(Resources res)
public static int getMinPanelHeight(Resources res)
public static int getMinKeyboardHeight(Context context)
public static ViewTreeObserver.OnGlobalLayoutListener attach(Activity activity, IPanelHeightTarget target, KeyboardUtil.OnKeyboardShowingListener lis)
Activity.onCreate(Bundle)
For align the height of the keyboard to target as much as possible.
For save the refresh the keyboard height to shared-preferences.activity - contain the viewtarget - whose height will be align to the keyboard height.lis - the listener to listen in: keyboard is showing or not.saveKeyboardHeight(Context, int)public static ViewTreeObserver.OnGlobalLayoutListener attach(Activity activity, IPanelHeightTarget target)
public static void detach(Activity activity, ViewTreeObserver.OnGlobalLayoutListener l)
activity - same activity used in attach(android.app.Activity, cn.dreamtobe.kpswitch.IPanelHeightTarget, cn.dreamtobe.kpswitch.util.KeyboardUtil.OnKeyboardShowingListener) methodl - ViewTreeObserver.OnGlobalLayoutListener returned by attach(android.app.Activity, cn.dreamtobe.kpswitch.IPanelHeightTarget, cn.dreamtobe.kpswitch.util.KeyboardUtil.OnKeyboardShowingListener) method