相关疑难解决方法(0)

Android:如何防止软键盘向上推?

我的应用程序底部有一个垂直滑动抽屉.当软键盘打开时,它会向上推动抽屉的标签,使其位于键盘顶部.我实际上希望它保持在屏幕的底部,当键盘显示时隐藏.

其他人遇到这个问题?知道如何解决它吗?

keyboard layout android view

352
推荐指数
15
解决办法
26万
查看次数

windowSoftInputMode ="adjustResize"不适用于半透明动作/导航栏

我在新的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

117
推荐指数
8
解决办法
8万
查看次数

显示软键盘时向上移动布局

当编辑文本获得焦点后出现软键盘时,我试图调整布局。现在,如果我有很多编辑文本并且键盘出现,则最后一个编辑文本被隐藏并且我无法向上滚动。

这是我的布局是如何构建的:

模板:

<LinearLayout>
    <LinearLayout>
        // header 1
    </LinearLayout>
    <LinearLayout>
        // header 1
    </LinearLayout>
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:orientation="vertical">
        // where I inflate view_1
    </LinearLayout>
    <LinearLayout>
        // footer
    </LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

视图 (view_1):

<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:focusable="true"
        android:focusableInTouchMode="true">
        <LinearLayout>
            // ...
        </LinearLayout>
        <LinearLayout>
            // ...
        </LinearLayout>
        <LinearLayout>
            <TextView/>
            <EditText/>
            <TextView/>
            <EditText/>
            <TextView/>
            <EditText/>
            <TextView/>
            <EditText/>
        </LinearLayout>
    </LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)

我已经尝试了android:windowSoftInputMode(在 manifest.xml 上和以编程方式)的各种组合。我试图设置android:isScrollContainer="false"滚动视图,但没有。

我也试过这个答案,在我的滚动视图中放置了一个 GlobalLayoutListener ,但是当键盘出现时没有调用 onGlobalLayout 。而且isKeyboardShown总是假的。

android soft-keyboard

4
推荐指数
2
解决办法
2万
查看次数