11package sj .keyboard .widget ;
22
3+ import android .app .Activity ;
34import android .content .Context ;
5+ import android .content .res .Configuration ;
6+ import android .graphics .Rect ;
47import android .util .AttributeSet ;
58import android .view .View ;
69import android .view .ViewGroup ;
@@ -13,9 +16,10 @@ public abstract class AutoHeightLayout extends SoftKeyboardSizeWatchLayout imple
1316
1417 private static final int ID_CHILD = R .id .id_autolayout ;
1518
16- protected int mSoftKeyboardHeight ;
17- protected int mMaxParentHeight ;
1819 protected Context mContext ;
20+ protected int mMaxParentHeight ;
21+ protected int mSoftKeyboardHeight ;
22+ protected boolean mConfigurationChangedFlag = false ;
1923
2024 public AutoHeightLayout (Context context , AttributeSet attrs ) {
2125 super (context , attrs );
@@ -65,8 +69,26 @@ public void updateMaxParentHeight(int maxParentHeight) {
6569 }
6670 }
6771
72+ @ Override
73+ protected void onConfigurationChanged (Configuration newConfig ) {
74+ super .onConfigurationChanged (newConfig );
75+ mConfigurationChangedFlag = true ;
76+ mScreenHeight = 0 ;
77+ }
78+
6879 @ Override
6980 protected void onMeasure (int widthMeasureSpec , int heightMeasureSpec ) {
81+ if (mConfigurationChangedFlag ){
82+ mConfigurationChangedFlag = false ;
83+ Rect r = new Rect ();
84+ ((Activity ) mContext ).getWindow ().getDecorView ().getWindowVisibleDisplayFrame (r );
85+ if (mScreenHeight == 0 ) {
86+ mScreenHeight = r .bottom ;
87+ }
88+ int mNowh = mScreenHeight - r .bottom ;
89+ mMaxParentHeight = mNowh ;
90+ }
91+
7092 if (mMaxParentHeight != 0 ) {
7193 int heightMode = MeasureSpec .getMode (heightMeasureSpec );
7294 int expandSpec = MeasureSpec .makeMeasureSpec (mMaxParentHeight , heightMode );
0 commit comments