繁体   English   中英

EditText 在 Android 中被软键盘隐藏

[英]EditText is hidden by the softkeyboard in Android

我在编辑文本上有一个具有视差效果的应用程序布局,我的问题是 **当我点击编辑文本软键盘时会隐藏我的编辑文本?**有人可以帮我吗? “这在我的情况下不起作用。

清单中的代码

<activity
            android:name="one.tusk.stush.activities.NewPostDetailActivity"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="adjustResize|adjustPan" >

在你的清单中试试这个,

<activity
        android:name=".rapcalsy.MainActivity"
        android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

根据此更改您的布局,不要错过以下行

android:isScrollContainer="true"

 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scrollview"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:isScrollContainer="true"
    android:orientation="vertical">

    <TableLayout
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:background="#000000"
        android:padding="0dp"
        android:stretchColumns="*">
        ...
    </TableLayout>
</ScrollView>

您应该只使用android:windowSoftInputMode="adjustResize"

如果这还不够,您可能需要将属性android:fitsSystemWindows="true"到包含您的 EditText 的根布局。

请试试这个。

在 Manifest中将 android:softInputMode属性设置为adjustResize并将父布局放在ScrollView 中 希望这会有所帮助。

我像你说的那样尝试了一下然后我得到了这个工作编辑你的清单文件

    <activity
                android:name="one.tusk.stush.activities.NewPostDetailActivity"
                android:screenOrientation="portrait"
                android:windowSoftInputMode="stateVisible" >

然后在java类的oncreate中添加以下代码行

 getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);  

这样键盘就不会直接/总是向您显示

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM