关于弹出窗口的输入法挡住按钮问题
来源:互联网 发布:淘宝全国联保服务申请 编辑:程序博客网 时间:2024/05/15 06:46
网上一般提供的两种方法都是调整edittext控件的高度
方案一、把整个布局文件用ScrollView套住。这样当你聚焦时虽然输入法也能够挡住一些输入框,但是你可以通过手动滑动看被挡住的内容。
方案二、在Activity中设置android:windowSoftInputMode="adjustResize" 解释: 使得该Activity主窗口总是被调整屏幕的大小以便留出软键盘的空间。就是把布局内容顶上去一遍能够看到界面的所有内容,而不会被键盘遮挡
我们实际的需求是输完内容,可以直接点按钮提交。就是说edittext下有个按钮,我们需要看到。。。
先看下如下两张图,第一张,是弹出来的popupwindow ,黄色的edittext和下边的2个按钮。。
第二张是输入法弹出来后的效果。我们的需求就是如此:
如何实现了?方法如下,点击一个按钮调用下边的方法弹出popupwindow。。
private void popup() {
if (pWindow == null) {
View view = LayoutInflater.from(this).inflate(R.layout.mypopup,
null);
pWindow = new PopupWindow(view, ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
pWindow.setFocusable(true);
pWindow.setBackgroundDrawable(new BitmapDrawable());
pWindow.setTouchable(true);
pWindow.setOutsideTouchable(false);
pWindow.setSoftInputMode(android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
editText = (EditText) view.findViewById(R.id.etmsg);
view.findViewById(R.id.btnsend).setOnClickListener(this);
view.findViewById(R.id.btncancel).setOnClickListener(this);
}
pWindow.showAtLocation(getCurrentFocus(), Gravity.CENTER, 0, 0);
}
其中 ,mypopup.xml文件如下。原理很简单,就是让2个按钮的布局覆盖在edittext上边。。
<?xml version="1.0" encoding="utf-8"?><FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/FrameLayout1" android:layout_width="match_parent" android:layout_height="wrap_content" > <EditText android:id="@+id/etmsg" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="top" android:lines="15" android:background="#ffff00" android:paddingBottom="50dp" > </EditText> <LinearLayout android:layout_gravity="bottom" android:layout_height="50dp" android:background="#00ff00" android:layout_width="match_parent" > <Button android:id="@+id/btnsend" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="send" /> <Button android:id="@+id/btncancel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="cancel" /> </LinearLayout></FrameLayout>
- 关于弹出窗口的输入法挡住按钮问题
- Android 输入法弹出框挡住界面问题
- android edittext弹出输入法的窗口问题
- 关于键盘弹出挡住输入框的问题
- h5安卓浏览器,弹出框里的输入框被输入法挡住的问题
- C# winform 按钮弹出窗口的问题
- 关于输入法的弹出
- 输入法弹出的问题
- android 输入法弹出时不能挡住按钮把布局顶上去
- 关于点击按钮弹出iframe窗口的前端代码
- 融云 输入法弹出窗口 监听系列问题
- 关于Android让页面默认弹出输入法的问题
- Android 关于 EditText 的一些问题 如:不弹出输入法
- 关于EditText默认会弹出输入法的问题
- 关于Android弹出输入法后页面需要上移的问题。
- 如何解决Android中输入法挡住输入框的问题
- 如何解决Android中输入法挡住输入框的问题
- android 中解决输入法挡住输入框的问题
- 一致性哈希算法
- CSS的position/float/display的取值方法
- Cocos2d-x 多分辨率适配完全解析
- ⑥Java中函数执行顺序
- 网址
- 关于弹出窗口的输入法挡住按钮问题
- 第四章表达式
- Failed to lookup provider 'shm' for 'slotmem': is mod_slotmem_shm loaded??
- C# 操作excel 常见问题解决方案
- IOS中的CommonCryptor.h
- 这四个故事揭示与盖茨共事的真相
- Android declare-styleable:自定义控件的属性(attr.xml,TypedArray)的使用
- Shell 常见问题列表
- VIM快捷键大全