我需要做一个非常简单的事情 - 找出是否显示了软件键盘.这在Android中可行吗?
我想在软键盘激活时调整/重新调整布局大小,如下所示:
之前和之后:


在SO中找到了几个资源:
但问题和答案相当模糊,这里的问题是我想要的更清晰的画面.
要求:
我在新的Android KitKat(4.4)中使用半透明操作栏/导航栏时出现问题windowSoftInputMode="adjustResize".
Normaly将InputMode更改为adjustResize,应用程序应该在键盘显示时自行调整大小......但是在这里它不会!如果我删除透明效果的行,则调整大小正常.
因此,如果键盘可见,我的ListView就在它下面,我无法访问最后几个项目.(只能手动隐藏键盘)
AndroidManifest.xml中
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="XYZ"
android:versionCode="23"
android:versionName="0.1" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.XYZStyle" >
<activity
android:name="XYZ"
android:label="@string/app_name"
android:windowSoftInputMode="adjustResize" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
值-V19/styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.XYZStyle" parent="@style/Theme.AppCompat.Light">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
fragment.xml之
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/listView_contacts"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:divider="@null"
android:dividerHeight="0dp"
android:drawSelectorOnTop="true"
android:fastScrollAlwaysVisible="true"
android:fastScrollEnabled="true"
android:paddingBottom="@dimen/navigationbar__height" >
</ListView> …Run Code Online (Sandbox Code Playgroud) android resize statusbar window-soft-input-mode android-4.4-kitkat
我有一个<ScrollView>布局:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/my_scrollview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="@+id/input_one"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:inputType="number" >
<EditText
android:id="@+id/input_two"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:inputType="number" >
<EditText
android:id="@+id/input_three"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:inputType="number" >
<Button
android:id="@+id/ok_btn"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:text="@string/ok_str" />
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
如上所示,简单布局包含三个输入字段和一个"确定"按钮.
我使用上面的布局运行我的应用程序,当我点击第一个输入字段(@+id/input_one)时,软键盘将从屏幕底部弹出,它隐藏第三个输入字段和"确定"按钮.
自从我使用以来<ScrollView>,我想我可以向上滚动页面以查看第三个输入字段和软键盘隐藏的"确定"按钮,但页面不可滚动.为什么?如何摆脱它?基本上,我想看到每个输入字段和"确定"按钮,甚至软键盘弹出.
android android-keypad android-intent android-layout android-scrollview
我创建了一个简单的iPhone/Android应用程序,包含一个普通的webview.此webview调用我的网站.
在我的网站上有几种输入类型= text或textarea的表单.当它们位于页面底部时,我遇到了问题!
1)在我的iPhone应用程序中,键盘将自动出现并将文本框推送到手机屏幕的可见区域.所以没有什么可做的.
2)但是在我的Android应用程序中,文本框将保持在同一个位置,并最终被我的键盘隐藏.所以用户唯一的选择是输入"盲".
我怎样才能解决这个问题?有没有其他人遇到这个问题?
我正在尝试创建一个非常基本的聊天屏幕,其中ListView显示文本,底部是EditText,EditText右侧是"发送"按钮.一切都很实用,但当我点击EditText时,虚拟键盘会覆盖它.屏幕平移一点但不足以在键盘上方可见.我的清单中有"adjustPan"标签,并且还尝试了"adjustResize"标签无效.我猜这与我的布局设置方式有关,但老实说我没有任何线索.请帮忙!
当前布局......
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView android:id="@+id/android:list"
android:layout_height="0dip"
android:layout_width="fill_parent"
android:layout_weight="1"
android:stackFromBottom="true">
</ListView>
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<EditText android:id="@+id/sendMessageBox"
android:focusable="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scrollbars="vertical"
android:maxLines="4"
android:text=""
android:inputType="textShortMessage|textAutoCorrect|textCapSentences|textMultiLine"
android:maxLength="1000"
android:hint="Type your message..."
android:imeOptions="actionSend"/>
<Button android:id="@+id/sendMessageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:text="Send"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
android android-manifest android-layout android-softkeyboard
我在一些应用程序中看到,当显示软键盘时,布局会发生变化.这当然不是adjustPan因为整个布局(可能是内部布局)的变化,而不仅仅是当前的变化EditText.例如,这是在Evernote登录屏幕中.你能告诉我这是怎么做的吗?
我们在我们的应用程序中应用了新的Android KitKat半透明主题,当键盘出现时,我们遇到了一个奇怪的问题.如果我们不使用新android:windowTranslucentStatus属性,则所有内容都照常工作:屏幕调整大小,并且所有内容都保持可见.但是当我们使用时android:windowTranslucentStatus,屏幕不会调整大小,我们EditText会被键盘隐藏.
问题的一个示例:

屏幕之间的唯一区别在于样式中的属性:
第一个屏幕:
<item name="android:windowTranslucentStatus">false</item>
第二个屏幕:
<item name="android:windowTranslucentStatus">true</item>
我们认为这是Kitkat发布的一个错误,但我们希望您了解这一点.我们有点生气了.当然,如果有人有解决方案,那将是惊人的.
编辑:我刚刚将此问题添加到Android问题跟踪器.您可能有兴趣主演此问题:https://issuetracker.google.com/issues/36986276
有没有办法知道屏幕上显示的键盘大小?
我正在使用Cocos2dx进行编程,但我想知道Android部分或Cocos部分屏幕中显示的键盘高度,这没关系.
我知道Keyboard有一个getHeight()方法,但我不想创建新的键盘,我想使用默认键盘.