Fix media keyboard sizing issue by trying two ways to find window insets.
This commit is contained in:
parent
3a21a2a49e
commit
875895524e
1 changed files with 20 additions and 0 deletions
|
@ -25,6 +25,7 @@ import android.preference.PreferenceManager;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.WindowInsets;
|
||||||
|
|
||||||
import androidx.appcompat.widget.LinearLayoutCompat;
|
import androidx.appcompat.widget.LinearLayoutCompat;
|
||||||
|
|
||||||
|
@ -120,6 +121,25 @@ public class KeyboardAwareLinearLayout extends LinearLayoutCompat {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onAttachedToWindow() {
|
||||||
|
super.onAttachedToWindow();
|
||||||
|
if (Build.VERSION.SDK_INT >= 23 && getRootWindowInsets() != null) {
|
||||||
|
int bottomInset;
|
||||||
|
WindowInsets windowInsets = getRootWindowInsets();
|
||||||
|
if (Build.VERSION.SDK_INT >= 30) {
|
||||||
|
bottomInset = windowInsets.getInsets(WindowInsets.Type.navigationBars()).bottom;
|
||||||
|
} else {
|
||||||
|
bottomInset = windowInsets.getStableInsetBottom();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bottomInset != 0 && (viewInset == 0 || viewInset == statusBarHeight)) {
|
||||||
|
Log.i(TAG, "Updating view inset based on WindowInsets. viewInset: " + viewInset + " windowInset: " + bottomInset);
|
||||||
|
viewInset = bottomInset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@TargetApi(VERSION_CODES.LOLLIPOP)
|
@TargetApi(VERSION_CODES.LOLLIPOP)
|
||||||
private int getViewInset() {
|
private int getViewInset() {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Add table
Reference in a new issue