zhangxq / keyboardheightprovider Goto Github PK
View Code? Open in Web Editor NEW设置activity的 android:windowSoftInputMode="adjustNothing"情况下,获取键盘高度
设置activity的 android:windowSoftInputMode="adjustNothing"情况下,获取键盘高度
Similarly to issue #4, activity leaks if the class is destroyed before the runnable is consumed.
HeightProvider.java
The following code leaks the activity:
public HeightProvider init() {
if (!isShowing()) {
final View view = mActivity.getWindow().getDecorView();
// 延迟加载popupwindow,如果不加延迟就会报错
view.post(new Runnable() {
@Override
public void run() {
showAtLocation(view, Gravity.NO_GRAVITY, 0, 0);
}
});
}
return this;
}
Calling dismiss()
before terminating the activity should fix it.
E/WindowManager: android.view.WindowLeaked: Activity com.example.schoolairdrop.ui.activity.ChatActivity has leaked window android.widget.PopupWindow$PopupViewContainer{1557c1fd V.E..... ......ID 0,0-0,926} that was originally added here
at android.view.ViewRootImpl.(ViewRootImpl.java:379)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:260)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:74)
at android.widget.PopupWindow.invokePopup(PopupWindow.java:1122)
at android.widget.PopupWindow.showAtLocation(PopupWindow.java:938)
at android.widget.PopupWindow.showAtLocation(PopupWindow.java:902)
at com.example.schoolairdrop.ui.utils.HeightProvider$1.run(HeightProvider.java:47)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5318)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:922)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:717)
public HeightProvider init() {
if (!isShowing()) {
final View view = mActivity.getWindow().getDecorView();
// Delay loading popupwindow, if not, error will be reported
view.post(new Runnable() {
@OverRide
public void run() {
showAtLocation(view, Gravity.NO_GRAVITY, 0, 0);//错误出在这里…
}
});
}
return this;
}
vivo Y85A 8.1.0 获取高度为0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.