-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Soft KeyBoard problem #877
Comments
@MatteCarra the problem is that we require the FULLSCREEN flag, so we can display the There were long discussions about this here: |
I have already Turned on keyboardSupport... |
@MatteCarra yeah it is no perfect solution. It may needs adjustments in landscape mode. |
Ok thank you. P.s: |
@MatteCarra i'm really sorry for this. I still hope someone comes up with a better solution.
|
This solution doesn't work. To reproduce this bug:
|
@MatteCarra you also disabled the keyboardutil? |
Ops I forget. |
perhaps you can open/close the keyboard when rotating? |
I will try, but I think to had already tried this solution. |
The sample app includes the KeyboardUtil Drawer, try if it also occurs there. Just tried the keyboard is closed after rotation |
Yes but after rotation click latest edittext and try to write hello |
Have you the same problem? |
@MatteCarra i will check. But the KeyboardUtil shouldn't be the problem as it is recreated after the screen is rotated. |
No. That isn't the problem. |
In keyboard util System.out.println(heightDiffDp - initialDpDiff) after rotating it becomes negative like -482.33334 so the layout doesn't change when keyboard comes up (this happens only when you rotate with keyboard open) |
So you do not recreate the activity as it is recommended? I assume you have the I highly recommend you to recreate the activity and remember the previous state via the |
No configChanges! My manifest => http://pastebin.com/iuGie38m Values after 2 rotations (final portait) with keyboard open: Rotation without keyboard open: |
@MatteCarra i have modified some things of the I hope it improves the behavior on your side too /*
* Copyright 2015 Mike Penz All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mikepenz.materialdrawer.util;
import android.app.Activity;
import android.graphics.Rect;
import android.os.Build;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.inputmethod.InputMethodManager;
/**
* Created by mikepenz on 14.03.15.
* This class implements a hack to change the layout padding on bottom if the keyboard is shown
* to allow long lists with editTextViews
* Basic idea for this solution found here: http://stackoverflow.com/a/9108219/325479
*/
public class KeyboardUtil {
private View decorView;
private View contentView;
public KeyboardUtil(Activity act, View contentView) {
this.decorView = act.getWindow().getDecorView();
this.contentView = contentView;
//only required on newer android versions. it was working on API level 19
if (Build.VERSION.SDK_INT >= 19) {
decorView.getViewTreeObserver().addOnGlobalLayoutListener(onGlobalLayoutListener);
}
}
public void enable() {
if (Build.VERSION.SDK_INT >= 19) {
decorView.getViewTreeObserver().addOnGlobalLayoutListener(onGlobalLayoutListener);
}
}
public void disable() {
if (Build.VERSION.SDK_INT >= 19) {
decorView.getViewTreeObserver().removeOnGlobalLayoutListener(onGlobalLayoutListener);
}
}
//a small helper to allow showing the editText focus
ViewTreeObserver.OnGlobalLayoutListener onGlobalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
Rect r = new Rect();
//r will be populated with the coordinates of your view that area still visible.
decorView.getWindowVisibleDisplayFrame(r);
int height = decorView.getContext().getResources().getDisplayMetrics().heightPixels;
int bottom = r.bottom;
//if it could be a keyboard add the padding to the view
if (bottom - height != 0) {
// if the use-able screen height differs from the total screen height we assume that it shows a keyboard now
//check if the padding is 0 (if yes set the padding for the keyboard)
if (contentView.getPaddingBottom() == 0) {
//set the padding of the contentView for the keyboard
contentView.setPadding(0, 0, 0, height - bottom);
}
} else {
//check if the padding is != 0 (if yes reset the padding)
if (contentView.getPaddingBottom() != 0) {
//reset the padding of the contentView
contentView.setPadding(0, 0, 0, 0);
}
}
}
};
/**
* Helper to hide the keyboard
*
* @param act
*/
public static void hideKeyboard(Activity act) {
if (act != null && act.getCurrentFocus() != null) {
InputMethodManager inputMethodManager = (InputMethodManager) act.getSystemService(Activity.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(act.getCurrentFocus().getWindowToken(), 0);
}
}
} |
Yes :) |
I understand why: if (contentView.getPaddingBottom() == 0) <- problem Because when I rotate it has already a padding, but it needs to be updated! |
//a small helper to allow showing the editText focus
ViewTreeObserver.OnGlobalLayoutListener onGlobalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
Rect r = new Rect();
//r will be populated with the coordinates of your view that area still visible.
decorView.getWindowVisibleDisplayFrame(r);
int height = decorView.getContext().getResources().getDisplayMetrics().heightPixels;
int bottom = r.bottom;
//if it could be a keyboard add the padding to the view
if (bottom - height != 0) {
// if the use-able screen height differs from the one is set then we update padding
int diff = height - bottom;
if (contentView.getPaddingBottom() != diff) {
//set the padding of the contentView for the keyboard
contentView.setPadding(0, 0, 0, diff);
}
} else {
//check if the padding is != 0 (if yes reset the padding)
if (contentView.getPaddingBottom() != 0) {
//reset the padding of the contentView
contentView.setPadding(0, 0, 0, 0);
}
}
}
}; |
@MatteCarra thanks i will check again. |
MaterialDrawer is causing some problem with keyboard.
When I am in landscape mode I click an edittext then keyboard opens.
Then I rotate the device and the bug happens!
Bug here: http://stackoverflow.com/questions/34204230/soft-keyboard-push-up-hidding-action-bar-or-overlay-edittext
I tried to remove this library and all works.
Today I will try to update this library
The text was updated successfully, but these errors were encountered: