Created
July 30, 2015 07:32
-
-
Save Krishan14sharma/677f9799accdcdccd775 to your computer and use it in GitHub Desktop.
softkeyboard listner layout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.zapbuild.myi.ui.view; | |
| import android.content.Context; | |
| import android.util.AttributeSet; | |
| import android.widget.LinearLayout; | |
| public class MyLayout extends LinearLayout { | |
| public MyLayout(Context context, AttributeSet attrs) { | |
| super(context, attrs); | |
| } | |
| public MyLayout(Context context) { | |
| super(context); | |
| } | |
| private OnSoftKeyboardListener onSoftKeyboardListener; | |
| @Override | |
| protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) { | |
| if (onSoftKeyboardListener != null) { | |
| final int newSpec = MeasureSpec.getSize(heightMeasureSpec); | |
| final int oldSpec = getMeasuredHeight(); | |
| if (oldSpec > newSpec){ | |
| onSoftKeyboardListener.onShown(); | |
| } else { | |
| onSoftKeyboardListener.onHidden(); | |
| } | |
| } | |
| super.onMeasure(widthMeasureSpec, heightMeasureSpec); | |
| } | |
| public final void setOnSoftKeyboardListener(final OnSoftKeyboardListener listener) { | |
| this.onSoftKeyboardListener = listener; | |
| } | |
| public interface OnSoftKeyboardListener { | |
| public void onShown(); | |
| public void onHidden(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment