当软键盘处于活动状态并且我已成功实现它时,我已经研究了很多调整布局但是当我android:theme="@android:style/Theme.NoTitleBar.Fullscreen"在清单文件中的活动标签中使用它时问题就出现了.
为此,我使用android:windowSoftInputMode="adjustPan|adjustResize|stateHidden"了不同的选项,但没有运气.
之后,我以FullScreen编程方式实现并尝试了各种布局,FullScreen但都是徒劳的.
我引用了这些链接,并在此处查看了许多与此问题相关的帖子:
http://android-developers.blogspot.com/2009/04/updating-applications-for-on-screen.html
http://davidwparker.com/2011/08/30/android-how-to-float-a-row-above-keyboard/
这是xml代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/masterContainerView"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#ffffff">
<ScrollView android:id="@+id/parentScrollView"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical">
<TextView android:id="@+id/setup_txt" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Setup - Step 1 of 3"
android:textColor="@color/top_header_txt_color" android:textSize="20dp"
android:padding="8dp" android:gravity="center_horizontal" />
<TextView android:id="@+id/txt_header" android:layout_width="fill_parent"
android:layout_height="40dp" android:text="AutoReply:"
android:textColor="@color/top_header_txt_color" android:textSize="14dp"
android:textStyle="bold" android:padding="10dp"
android:layout_below="@+id/setup_txt" />
<EditText android:id="@+id/edit_message"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:text="Some text here." android:textSize="16dp"
android:textColor="@color/setting_editmsg_color" android:padding="10dp"
android:minLines="5" android:maxLines="6" android:layout_below="@+id/txt_header"
android:gravity="top" android:scrollbars="vertical"
android:maxLength="132" />
<ImageView android:id="@+id/image_bottom"
android:layout_width="fill_parent" android:layout_height="wrap_content" …Run Code Online (Sandbox Code Playgroud) 当我将焦点放在iScroll视图底部的表单域时,它不会向上/向上移动/将焦点字段带到softkeyboad上方.任何的想法?谢谢!

这是Android项目. https://dl.dropboxusercontent.com/u/75818136/webkitdemo.zip
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<title>iScroll demo: simple</title>
<style type="text/css" media="all">
body,ul,li {
padding:0;
margin:0;
border:0;
}
body {
font-size:12px;
-webkit-user-select:none;
-webkit-text-size-adjust:none;
font-family:helvetica;
}
#header {
position:absolute; z-index:2;
top:0; left:0;
width:100%;
height:45px;
line-height:45px;
background-color:#d51875;
background-image:-webkit-gradient(linear, 0 0, 0 100%, color-stop(0, #fe96c9), color-stop(0.05, #d51875), color-stop(1, #7b0a2e));
background-image:-moz-linear-gradient(top, #fe96c9, #d51875 5%, #7b0a2e);
background-image:-o-linear-gradient(top, #fe96c9, #d51875 5%, #7b0a2e);
padding:0;
color:#eee;
font-size:20px;
text-align:center;
}
#header a {
color:#f3f3f3;
text-decoration:none;
font-weight:bold;
text-shadow:0 -1px 0 …Run Code Online (Sandbox Code Playgroud) 我正在使用Worklight开发混合应用程序,我遇到以下问题:
当用户点击输入字段时,弹出的软键盘会在屏幕上相对较低时隐藏输入字段.页面是可滚动的,因此用户可以滚动并再次查看该字段,但客户要求定义页面将自动滚动,直到该字段可见.
请注意,这仅在Android环境中发生.在iPhone和iPad环境中,默认行为是所需的行为.
根据我的发现,诀窍应该通过android:windowSoftInputModeAndroid清单文件中的属性来完成.但是,我在那里的所有努力都未能实现自动滚动.
如果有一个特定于Worklight的解决方案,我宁愿使用它,而不是干预Android本机代码.
当软键盘弹出时,我希望能够在Android上调整我的UI屏幕.
所以,我在下面的第一张图片和屏幕底部的EditText有类似的东西,当用户点击EditText时,我想要与第二张图片中发生的情况相同.
也就是说,EditText向上移动并且似乎"坐"在软键盘的顶部,当软键盘消失时,它应该返回到其先前的状态.
谁能让我知道接近和实现这个的最佳方法?
alt text http://img40.imageshack.us/img40/2300/keyboarddown.png
alt text http://img46.imageshack.us/img46/9339/keyboardup.png
通常在横向模式下,EditText将以全屏模式打开IME,但是对于webview中的文本字段(作为HTML内容加载),它不会,并且它会向上推动现有视图.尝试使用'adjustpan'选项,但无济于事.在这种情况下是否可以更改IME?提前致谢...
我有一个ActionView带菜单项ActionBar(使用ActionBarSherlock),我可以在其中显示EditText一个搜索字段.这是一个Activity用CustomViewActionBar 启动另一个的输入,它显示相同的布局(我没有使用任何东西来强制它SoftKeyboard出现在第二个活动中,这里没有问题).当我想让第一个活动中的视图崩溃时软键盘自动显示/消失,我使用:
openKeyboard方法
mImm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
Run Code Online (Sandbox Code Playgroud)
closeKeyboard方法
mImm.hideSoftInputFromWindow(edittext.getWindowToken(), 0);
Run Code Online (Sandbox Code Playgroud)
我使用它ActionExpandListener来使SoftKeyboard在View展开或折叠时出现或消失.通过以上两种方法,我得到了预期的结果.我在几个关于SO的问题上发现了这一点(特别是关闭/隐藏Android软键盘并在ActionBar上显示SearchView的软键盘或强制打开软键盘).
只是为了理解,当我使用SHOW_IMPLICIT或SHOW_FORCED单独使用时,它对较低版本没有影响(如2. +).EditText是专注的,但键盘没有出现(所以,你猜它是一件坏事).在最近的版本中(例如4. +),这是一个很好的效果,没有问题.然后,我强制键盘显示上面的openKeyboard方法.
现在,我遇到了一些麻烦...
在较低的版本中,我在键盘创建/销毁之前和之后得到了"空"空间,我可以忍受这个.但是在最近的版本中,当我返回第一个Activity时,我得到了"空"空间.而且它在不到一秒的时间就在这里,但足以看到它!
为了更好地了解会发生什么,请参见下图:
1.第二项活动:我按下向上主页按钮 - 键盘正常消失.
2.(返回)第一个活动:我的ListView被一个"空"空间覆盖(我的应用程序中的背景颜色).它消失了(这与SoftKeyboard的高度相同,毫无疑问!)
我想这是因为我强迫键盘出现在我的第一个活动中,虽然我在第二次活动时也强迫键盘隐藏,但是当我返回第一个活动时如何解决"空"空间?
摘要
1)活动=>按菜单中的项目>查看折叠>显示键盘>点击文本>发送>隐藏键盘>启动B活动.
2)B activity => setCustomView in actionbar>仅在编辑文本被聚焦/点击时显示键盘>点击文本>发送>隐藏键盘>刷新内容>按主页按钮>返回活动
3)活动=>"空"屏幕>屏幕消失.
任何帮助将非常感激.
谢谢你的时间.
编辑
我添加了我的第一堂课的代码,看看是否有人告诉我我做错了什么.也许这是我的代码问题.
菜单(ActionView)
ActionBar actionBar;
MenuItem …Run Code Online (Sandbox Code Playgroud) 简单地说,在webview中加载内容并点击文本字段后,我的应用程序拒绝调整大小或平移.
这是我的设置
我有一个包含多个片段的Activity.这是片段容器的布局.
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- MAIN CONTENT -->
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white" />
<RelativeLayout
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start">
<!-- ... -->
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
这是webview片段的布局.
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/tbOnlinePayment"
layout="@layout/toolbar" />
<WebView
android:layout_below="@+id/tbOnlinePayment"
android:id="@+id/paymentWebView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<ProgressBar
android:id="@android:id/progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我的应用程序的主题延伸 Theme.AppCompat.Light.DarkActionBar
我尝试过的:
android:windowSoftInputMode="adjustResize"和android:windowSoftInputMode="adjustPan".android:windowSoftInputMode="adjustResize"无法使用,但我不会手动强制执行此操作.我在这里放置应用程序的主题,因为也许有人知道这个主题以某种方式强制全屏.<item name="android:windowFullscreen">false</item>到应用程序的主题,但仍然没有结果.webview在一个scrollview.webview高度改为wrap_content.我想要的:
我不关心webview是调整大小还是推高.我想要的是键盘不隐藏输入字段.
在 Android 网页视图中,当触摸文本/密码字段时,键盘会出现但会覆盖该字段,迫使用户滚动以查看他们正在键入的内容。
有没有办法解决这个问题,或者有办法在网络视图中自动对焦?(如在 iOS 中所见)。
显现
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dedalos.amb">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name=".MyApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:usesCleartextTraffic="true"
android:windowSoftInputMode="adjustPan"
android:theme="@style/AppTheme">
<activity android:name=".SplashScreen" android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity">
</activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@color/splash_background"
tools:context=".MainActivity">
<WebView
android:id="@+id/ambWebViewLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/splash_background" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我还在这里粘贴样式和颜色:
颜色文件
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#008577</color>
<color name="colorPrimaryDark">#00574B</color>
<color name="colorAccent">#D81B60</color>
<color name="splash_background">#e11020</color>
</resources> …Run Code Online (Sandbox Code Playgroud) android ×7
webview ×3
javascript ×2
keyboard ×2
android-view ×1
field ×1
iscroll ×1
screen ×1
show-hide ×1