移动端html5 软键盘弹出事件时,会盖住下面的内容怎么处理

下次自动登录
关注移动互联网和移动APP开发工具、开发框架、测试工具、微信开发、Android源码、Android开源类库以及各种开源组件的IT科技网站
现在的位置:
android软键盘弹出,会把原来的界面挤上去的问题 处理方法
android软键盘弹出,会把原来的界面挤上去的问题
在项目的androidmanifest.xml文件中界面对应的&activity&里加入
android:oftinputmode=&adjustpan&
这样键盘就会覆盖屏幕。。
如果不想键盘覆盖屏幕,想让屏幕整体上移,就加入属性
android:windowsoftinputmode=&statevisible|adjustresize&
【上篇】【下篇】查看: 9178|回复: 15
安卓界面虚拟键盘弹出下面布局怎么顶上去
该用户从未签到主题帖子e币
&?xml version=&1.0& encoding=&utf-8&?&
&RelativeLayout xmlns:android=&/apk/res/android&
& & android:layout_width=&match_parent&
& & android:layout_height=&match_parent&
& & android:background=&@color/white& &
& & &RelativeLayout
& && &&&android:id=&@+id/relativeLayout1&
& && &&&android:layout_width=&match_parent&
& && &&&android:layout_height=&wrap_content&
& && &&&android:background=&@drawable/top& &
& && &&&&Button
& && && && &android:id=&@+id/btn_back&
& && && && &android:layout_width=&wrap_content&
& && && && &android:layout_height=&wrap_content&
& && && && &android:layout_alignParentLeft=&true&
& && && && &android:layout_centerVertical=&true&
& && && && &android:background=&@drawable/add_a_btn_selector&
& && && && &android:onClick=&goBack& /&
& && &&&&TextView
& && && && &android:id=&@+id/tv_login_title&
& && && && &android:layout_width=&wrap_content&
& && && && &android:layout_height=&wrap_content&
& && && && &android:layout_centerInParent=&true&
& && && && &android:layout_marginBottom=&5dp&
& && && && &android:layout_marginLeft=&20dp&
& && && && &android:layout_marginTop=&5dp&
& && && && &android:background=&@null&
& && && && &android:text=&评论&
& && && && &android:textColor=&@color/white&
& && && && &android:textSize=&15sp&
& && && && &android:textStyle=&bold& /&
& && &&&&Button
& && && && &android:id=&@+id/btn_send&
& && && && &android:layout_width=&wrap_content&
& && && && &android:layout_height=&wrap_content&
& && && && &android:layout_alignParentRight=&true&
& && && && &android:layout_centerVertical=&true&
& && && && &android:background=&@drawable/bdd_a_btn_selector& /&
& & &/RelativeLayout&
& & &EditText
& && &&&android:id=&@+id/comment_content&
& && &&&android:layout_width=&match_parent&
& && &&&android:layout_height=&200dip&
& && &&&android:layout_alignParentLeft=&true&
& && &&&android:layout_below=&@+id/relativeLayout1&
& && &&&android:layout_marginLeft=&10dip&
& && &&&android:layout_marginRight=&10dip&
& && &&&android:layout_marginTop=&16dp&
& && &&&android:background=&@drawable/editview_style_selector&
& && &&&android:cursorVisible=&true&
& && &&&android:ems=&10&
& && &&&android:gravity=&top&
& && &&&android:paddingLeft=&5dp& /&
& & &LinearLayout
& && &&&android:layout_width=&match_parent&
& && &&&android:layout_height=&wrap_content&
& && &&&android:layout_alignParentBottom=&true&
& && &&&android:orientation=&vertical& &
& && &&&&RelativeLayout
& && && && &android:layout_width=&match_parent&
& && && && &android:layout_height=&40dp&
& && && && &android:background=&@drawable/top& &
& && && && &&ImageView
& && && && && & android:id=&@+id/home_picdetail_iv_send&
& && && && && & android:layout_width=&wrap_content&
& && && && && & android:layout_height=&match_parent&
& && && && && & android:layout_alignParentLeft=&true&
& && && && && & android:layout_centerVertical=&true&
& && && && && & android:layout_marginLeft=&8dp&
& && && && && & android:src=&@drawable/toolviewemotionhl& /&
& && && && &&Button
& && && && && & android:id=&@+id/home_picdetail_bun_send&
& && && && && & android:layout_width=&wrap_content&
& && && && && & android:layout_height=&match_parent&
& && && && && & android:layout_alignParentRight=&true&
& && && && && & android:layout_centerVertical=&true&
& && && && && & android:layout_marginRight=&8dp&
& && && && && & android:background=&@drawable/contactsselectdone& /&
& && &&&&/RelativeLayout&
& && &&&&GridView
& && && && &android:id=&@+id/gv&
& && && && &android:layout_width=&fill_parent&
& && && && &android:layout_height=&wrap_content&
& && && && &android:columnWidth=&@dimen/space_35&
& && && && &android:fadingEdge=&none&
& && && && &android:gravity=&center&
& && && && &android:horizontalSpacing=&@dimen/space_5&
& && && && &android:numColumns=&auto_fit&
& && && && &android:scrollbars=&none&
& && && && &android:scrollingCache=&false&
& && && && &android:stretchMode=&columnWidth&
& && && && &android:verticalSpacing=&@dimen/space_5&
& && && && &android:visibility=&gone& &
& && &&&&/GridView&
& & &/LinearLayout&
&/RelativeLayout&
附件: 您需要
才可以下载或查看,没有帐号?
签到天数: 18 天连续签到: 1 天[LV.4]偶尔看看III主题帖子e币
搞个滚动给它就行了
那样就会好丑的!!!!&
该用户从未签到主题帖子e币
布局里面不要使用LinearLayout
该用户从未签到主题帖子e币
搞个滚动给它就行了
那样就会好丑的!!!!
签到天数: 60 天连续签到: 2 天[LV.6]常住居民II主题帖子e币
如果你把下面的布局顶上去了,你的EditView 就可能看不见了。用户还怎么输入信息呢?
签到天数: 60 天连续签到: 2 天[LV.6]常住居民II主题帖子e币
或者说,楼主是想做陌陌的那种效果?
&?xml version=&1.0& encoding=&utf-8&?&
&LinearLayout xmlns:android=&/apk/res/android&
& & android:layout_width=&match_parent&
& & android:layout_height=&match_parent&
& & android:orientation=&vertical& &
&include layout=&@layout/title_index& /&
& & &ScrollView
& && &&&android:layout_width=&fill_parent&
& && &&&android:layout_height=&fill_parent&
& && &&&android:fillViewport=&true& &
& && &&&&RelativeLayout
& && && && &android:layout_width=&fill_parent&
& && && && &android:layout_height=&wrap_content& &
& && && && &&RelativeLayout
& && && && && & android:id=&@+id/layout_content&
& && && && && & android:layout_width=&fill_parent&
& && && && && & android:layout_height=&fill_parent&
& && && && && & android:layout_marginBottom=&6.0dip&
& && && && && & android:layout_marginLeft=&6.0dip&
& && && && && & android:layout_marginRight=&6.0dip&
& && && && && & android:layout_marginTop=&8.0dip&
& && && && && & android:background=&@drawable/my_bg1&
& && && && && & android:minHeight=&150.0dip&
& && && && && & android:orientation=&vertical&
& && && && && & android:paddingBottom=&90.0dip& &
& && && && && & &EditText
& && && && && && &&&android:id=&@+id/mood_text&
& && && && && && &&&android:layout_width=&fill_parent&
& && && && && && &&&android:layout_height=&fill_parent&
& && && && && && &&&android:background=&@null&
& && && && && && &&&android:focusableInTouchMode=&true&
& && && && && && &&&android:gravity=&top&
& && && && && && &&&android:hint=&@string/moodtag&
& && && && && && &&&android:maxLength=&120&
& && && && && && &&&android:minHeight=&46.0dip&
& && && && && && &&&android:padding=&10.0dip&
& && && && && && &&&android:textSize=&16sp&
& && && && && && &&&&
& && && && && && &&&&requestFocus /&
& && && && && & &/EditText&
& && && && &&/RelativeLayout&
& && && && &&LinearLayout
& && && && && & android:id=&@+id/layout_syncicons&
& && && && && & android:layout_width=&wrap_content&
& && && && && & android:layout_height=&wrap_content&
& && && && && & android:layout_alignBottom=&@+id/layout_content&
& && && && && & android:layout_alignRight=&@+id/layout_content&
& && && && && & android:layout_marginBottom=&10.0dip&
& && && && && & android:layout_marginRight=&10.0dip&
& && && && && & android:layout_marginTop=&8.0dip&
& && && && && & android:gravity=&right|center&
& && && && && & android:orientation=&horizontal& &
& && && && && & &cn.fengso.taokezhushou.widget.SynchronousSharedView
& && && && && & android:id=&@+id/synchronous_shejiao&
& & & && && && && & android:layout_width=&wrap_content&
& & & && && && && & android:layout_height=&wrap_content&
& & & && && && && & /&
& && && && &&/LinearLayout&
& && && && &&TextView
& && && && && & android:id=&@+id/tv_textcount&
& && && && && & android:layout_width=&wrap_content&
& && && && && & android:layout_height=&wrap_content&
& && && && && & android:layout_above=&@+id/layout_syncicons&
& && && && && & android:layout_alignRight=&@+id/layout_syncicons&
& && && && && & android:layout_marginBottom=&5.0dip&
& && && && && & android:gravity=&center&
& && && && && & android:text=&0/120字&
& && && && && & android:visibility=&invisible&
& && && && && & android:textSize=&16.0sp& /&
& && && && &&RelativeLayout
& && && && && & android:id=&@+id/layout_camera&
& && && && && & android:layout_width=&100.0dip&
& && && && && & android:layout_height=&100.0dip&
& && && && && & android:layout_alignBottom=&@+id/layout_content&
& && && && && & android:layout_alignLeft=&@+id/layout_content&
& && && && && & android:layout_gravity=&left|center&
& && && && && & android:clickable=&true&
& && && && && & android:padding=&5.0dip& &
& && && && && & &ImageView
& && && && && && &&&android:id=&@+id/mood_img&
& && && && && && &&&android:layout_width=&fill_parent&
& && && && && & & & & & & & android:layout_height=&fill_parent&
& && && && && & & & & & & & android:scaleType=&centerCrop&
& & & & & & & & & & & & & & & & & & & & android:layout_margin=&5dp&
& && && && && && &&&android:focusable=&false&
& && && && && && &&&android:src=&@drawable/ic_feed_publish_photo_normal& /&
& & & & & & & & & & & & & & & & &View
& && && && && && &&&android:id=&@+id/iv_camera_cover&
& && && && && && &&&android:layout_width=&fill_parent&
& && && && && && &&&android:layout_height=&fill_parent&
& && && && && && &&&android:layout_margin=&5.0dip&
& && && && && && &&&android:background=&@drawable/bglistitem_selector_session_avatar&
& && && && && && &&&android:clickable=&true& /&
& && && && && & &View
& && && && && && &&&android:layout_width=&fill_parent&
& && && && && && &&&android:layout_height=&fill_parent&
& && && && && && &&&android:background=&@drawable/bg_feed_publish_photo_cover&
& && && && && && &&&android:focusable=&false& /&
& && && && &&/RelativeLayout&
& && && && &&ImageView
& && && && && & android:layout_width=&wrap_content&
& && && && && & android:layout_height=&wrap_content&
& && && && && & android:layout_alignBottom=&@+id/layout_content&
& && && && && & android:layout_alignParentLeft=&true&
& && && && && & android:layout_marginBottom=&10.0dip&
& && && && && & android:layout_marginLeft=&1.0dip&
& && && && && & android:src=&@drawable/ic_feed_publish_plus& /&
& && &&&&/RelativeLayout&
& & &/ScrollView&
&/LinearLayout&
签到天数: 18 天连续签到: 1 天[LV.4]偶尔看看III主题帖子e币
那你判断一下键盘弹出来的时候就在代码动态的设置你想显示的东西直接就放输入框下面就好了
签到天数: 62 天连续签到: 1 天[LV.6]常住居民II主题帖子e币
感觉定义在最底部的tabhost还有导航等等弹出软键盘自动就会顶到上面,看别人的需求都是避免顶上去-在Manifest.xml中当前的activity添加一个属性:“android:windowSoftInputMode=&adjustPan& ”
签到天数: 7 天连续签到: 1 天[LV.3]偶尔看看II主题帖子e币
8楼说的对。设置一下,软键盘弹出的时候布局不变就可以了
该用户从未签到主题帖子e币
可以了解一下软件盘弹出时候界面的几种的摸试,可以参考压缩的摸索,但愿对你有帮助!
头像被屏蔽
签到天数: 3 天连续签到: 1 天[LV.2]偶尔看看I主题帖子e币
提示: 作者被禁止或删除 内容自动屏蔽
签到天数: 16 天连续签到: 1 天[LV.4]偶尔看看III主题帖子e币
android:windowSoftInputMode 研究下这个
该用户从未签到主题帖子e币
谢谢各位,问题已解决,是主题设置问题, android:theme=&@android:style/Theme.NoTitleBar.Fullscreen&与android:windowSoftInputMode=&stateHidden|adjustResize&中的压缩模式起了冲突, 努力许久终于找到解决方案现在把方法献上,希望遇到有类似问题的朋友能够用到 首先写一个style如下[mw_shl_code=java,true]&style name=&dialogfullscreen& parent=&@android:style/Theme.Dialog&&
& && &&&&!-- 是否浮现在activity之上这里如果涉及到键盘上推adjustResize必须为true否则上推失效 --&
& && &&&&item name=&android:windowIsFloating&&true&/item&
& && &&&&item name=&android:windowFullscreen&&true&/item&
& && &&&&item name=&android:windowContentOverlay&&@null&/item&
& && &&&&!-- 无标题 --&
& && &&&&item name=&android:windowNoTitle&&true&/item&
& && &&&&!-- 边框 --&
& && &&&&item name=&android:windowFrame&&@null&/item&
& && &&&&!-- 设置半透明 --&
& && &&&&item name=&android:windowIsTranslucent&&true&/item&
& && &&&&item name=&android:windowBackground&&@android:color/transparent&/item&
& & &/style&[/mw_shl_code]
在注册activity时将主题设为
android:theme=&@style/dialogfullscreen&
在这后可能还会遇到个小问题 在跳入这个activity时由于是以dialog形式出现的所以可能连点会弹出多个界面
这只需跳转时控制一下就好了
终于搞定了嘿嘿希望有更好的方法出现
该用户从未签到主题帖子e币
在mainifest.xml文件中的activity标签下添加属性android:windowSoftInputMode=&adjustPan&
签到天数: 166 天连续签到: 1 天[LV.7]常住居民III主题帖子e币
那如果是fragment怎么设置
同问,朋友,你做出来了吗????&
浏览过的版块
QQ已认证,此人靠谱
社区认证会员
社区认证会员
推荐阅读热门话题
61882418416379326279279260257251226218210206715
半小时前2&小时前11&小时前昨天&23:49昨天&20:48昨天&18:56昨天&17:33昨天&17:17昨天&15:44昨天&14:06昨天&14:03昨天&10:50昨天&10:05前天&23:59前天&21:23前天&19:54
Powered by移动端 软键盘 弹出时 会影响布局
1)前段时间作的移动端页面,因为高度只有1页所以用了height:100%;width:100%;
ios下点击输入框弹出软键盘时,布局没有大影响。
当输入框可能被软键盘压到时,在一部分安卓下却出了问题,华为自带浏览器和UC会有布局上的问题。
原因可能是因为,软键盘弹出时,改变了height,使height:100%,不能达到原来的高度。
解决办法:
$(document).ready(function () {
  $('body').height($('body')[0].clientHeight);
页面加载完后,js给body一个定高。
2)以前还遇到过,移动端点击输入框时,页面向左偏移了一部分,但太久了,忘了什么浏览器了,重现不了,解决的方法是使输入框的大小居中.
PS:吐槽下华为自带浏览器和UC不识别css3的新单位,vw,vh.
阅读(...) 评论()Android软键盘遮挡的四种解决方案
Android软键盘遮挡的四种解决方案
[摘要:正在编纂框输进内容时会弹出硬键盘,而脚机屏幕地区有限每每会遮住输进界里,我们先看一下题目后果图: 输进用户名战暗码时,体系会弹出键盘,形成体系键盘会盖住文本框的题目,]
1 getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
android:windowSoftInputMode=&stateVisible|adjustResize&
&activity android:windowSoftInputMode=&stateVisible|adjustResize&. . . &
1 &ScrollView xmlns:android=&/apk/res/android& 2
android:layout_width=&fill_parent& android:layout_height=&fill_parent&& 3
&LinearLayout android:layout_width=&fill_parent& 4
android:layout_height=&fill_parent& android:orientation=&vertical&& 5
&/LinearLayout& 7 &/ScrollView&
1 &com.jereh.overidelinearlayout.LinearLayoutView xmlns:android=&/apk/res/android&
android:layout_width=&match_parent&
android:id=&@+id/login_root_layout&
android:layout_height=&match_parent&
4 android:orientation=&vertical&&
5 &!—这里模仿一个登录界面--&
&LinearLayout
android:id=&@+id/login_layout_logo&
android:layout_width=&match_parent&
android:layout_height=&0dp& 10
android:layout_weight=&10& 11
android:background=&#ff0000& 12
android:orientation=&vertical& & 13
&ImageView 14
android:id=&@+id/textView1& 15
android:layout_width=&fill_parent& 16
android:layout_height=&fill_parent& 17
android:src=&@drawable/login_logo& 18
android:scaleType=&fitXY&/& 19
&/LinearLayout& 20
&!—输入框和密码框--& 21
&LinearLayout 22
android:layout_width=&match_parent& 23
android:layout_height=&0dp& 24
android:layout_marginTop=&20dp& 25
android:layout_weight=&3& 26
android:orientation=&vertical& & 27
&EditText 28
android:id=&@+id/editText1& 29
android:layout_width=&match_parent& 30
android:layout_height=&wrap_content& 31
android:layout_alignLeft=&@+id/textView1& 32
android:layout_alignParentBottom=&true& 33
android:layout_gravity=&center_vertical& 34
android:hint=&用户名& 35
android:ems=&10& & 36
&requestFocus /& 37
&/EditText& 38
&EditText 40
android:id=&@+id/editText1& 41
android:layout_width=&match_parent& 42
android:layout_height=&wrap_content& 43
android:layout_alignLeft=&@+id/textView1& 44
android:layout_alignParentBottom=&true& 45
android:layout_gravity=&center_vertical& 46
android:hint=&密码& 47
android:ems=&10& & 48
&requestFocus /& 49
&/EditText& 50
&/LinearLayout& 51&/com.jereh.overidelinearlayout.LinearLayoutView&
protected void onSizeChanged(int w,final int h, int oldw,final int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
uiHandler.post(new Runnable() {
public void run() {
if (oldh - h & SOFTKEYPAD_MIN_HEIGHT){
软键盘关闭
keyBordStateListener.stateChange(KEYBORAD_SHOW);//回调方法显示部分区域
软键盘弹出
if(keyBordStateListener != null){
keyBordStateListener.stateChange(KEYBORAD_HIDE);// 回调方法隐藏部分区域 }
public interface KeyBordStateListener{
public void stateChange(int state);}//定义接口
private KeyBordStateListener
keyBordStateL
public void
setKeyBordStateListener(KeyBordStateListener keyBordStateListener) {
this.keyBordStateListener = keyBordStateL
} LinearLayoutView组件的完整代码: public class LinearLayoutView extends LinearLayout{
public static final int KEYBORAD_HIDE = 0;
public static final int KEYBORAD_SHOW = 1;
private static final int SOFTKEYPAD_MIN_HEIGHT = 50;
private Handler uiHandler = new Handler();
public LinearLayoutView(Context context) {
super(context);
public LinearLayoutView(Context context, AttributeSet attrs) {
super(context, attrs);
protected void onSizeChanged(int w,final int h, int oldw,final int oldh) {
// TODO Auto-generated method stub
super.onSizeChanged(w, h, oldw, oldh);
uiHandler.post(new Runnable() {
public void run() {
if (oldh - h & SOFTKEYPAD_MIN_HEIGHT){
keyBordStateListener.stateChange(KEYBORAD_SHOW);
if(keyBordStateListener != null){
keyBordStateListener.stateChange(KEYBORAD_HIDE);}
private KeyBordStateListener
keyBordStateL
public void 、setKeyBordStateListener(KeyBordStateListener keyBordStateListener) {
this.keyBordStateListener = keyBordStateL
public interface KeyBordStateListener{
public void stateChange(int state);
public class MainActivity extends Activity implements KeyBordStateListener { private LinearLayoutView resizeL
private LinearLayout logoL
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//获得可根据软键盘的弹出/关闭而隐藏和显示某些区域的LinearLayoutView组件
resizeLayout = (LinearLayoutView) findViewById(R.id.login_root_layout);
//获得要控制隐藏和显示的区域
logoLayout = (LinearLayout) findViewById(R.id.login_layout_logo);
resizeLayout.setKeyBordStateListener(this);//设置回调方法
//实现接口中的方法,该方法在resizeLayout的onSizeChanged方法中调用
public void stateChange(int state) {
// TODO Auto-generated method stub
switch (state) {
case LinearLayoutView.KEYBORAD_HIDE:
logoLayout.setVisibility(View.VISIBLE);
case LinearLayoutView.KEYBORAD_SHOW:
logoLayout.setVisibility(View.GONE);
感谢关注 Ithao123Android频道,是专门为互联网人打造的学习交流平台,全面满足互联网人工作与学习需求,更多互联网资讯尽在 IThao123!
Laravel是一套简洁、优雅的PHP Web开发框架(PHP Web Framework)。它可以让你从面条一样杂乱的代码中解脱出来;它可以帮你构建一个完美的网络APP,而且每行代码都可以简洁、富于表达力。
产品设计是互联网产品经理的核心能力,一个好的产品经理一定在产品设计方面有扎实的功底,本专题将从互联网产品设计的几个方面谈谈产品设计
Swift是Apple在WWDC2014所发布的一门编程语言,用来撰写OS X和iOS应用程序[1]。在设计Swift时.就有意和Objective-C共存,Objective-C是Apple操作系统在导入Swift前使用的编程语言
Swift是供iOS和OS X应用编程的新编程语言,基于C和Objective-C,而却没有C的一些兼容约束。Swift采用了安全的编程模式和添加现代的功能来使得编程更加简单、灵活和有趣。界面则基于广受人民群众爱戴的Cocoa和Cocoa Touch框架,展示了软件开发的新方向。
PHP(外文名:PHP: Hypertext Preprocessor,中文名:“超文本预处理器”)是一种通用开源脚本语言。语法吸收了C语言、Java和Perl的特点,利于学习,使用广泛,主要适用于Web开发领域。PHP 独特的语法混合了C、Java、Perl以及PHP自创的语法。它可以比CGI或者Perl更快速地执行动态网页。用PHP做出的动态页面与其他的编程语言相比,PHP是将程序嵌入到HTML(标准通用标记语言下的一个应用)文档中去执行,执行效率比完全生成HTML标记的CGI要高许多;PHP还可以执行编译后代码,编译可以达到加密和优化代码运行,使代码运行更快。
IThao123周刊}

我要回帖

更多关于 html5 软键盘弹出事件 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信