ViewTreeObserver.OnGlobalLayoutListener layoutListener =
new ViewTreeObserver.OnGlobalLayoutListener() {
int mScreenHeight = 0;
int mKeyboardHeight = 0;
@Override
public void onGlobalLayout() {
Rect rect = new Rect();
// 测量当前窗口的显示区域
((Activity)getContext()).getWindow().getDecorView()
.getWindowVisibleDisplayFrame(rect);
if(mScreenHeight <= 0){
mScreenHeight = ((WindowManager) getContext()
.getSystemService(Context.WINDOW_SERVICE))
.getDefaultDisplay().getHeight();
}
//计算出软键盘的高度
int keyboardHeight = mScreenHeight - rect.bottom;
//如果keyboardHeight大于屏幕的五分之一,
// 此时keyboardHeight有效,反之就是软键盘已经关闭了。
if (Math.abs(keyboardHeight) > mScreenHeight / 5) {
mKeyboardHeight = keyboardHeight;
}
}
}
<activity android:name=".activity.xxx" Android:windowSoftInputMode="stateVisible|adjustResize"/>
<style name="NoTitleDialogTheme" parent="android:style/Theme.Dialog">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowCloseOnTouchOutside">false</item>
</style>
<activity android:name=".FloatEditorActivity"
android:windowSoftInputMode="stateAlwaysVisible"
android:theme="@style/NoTitleDialogTheme"/>
public class FloatEditorActivity extends Activity implements View.OnClickListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.id.editorlayout);
getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
getWindow().setGravity(Gravity.BOTTOM);
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有