简体   繁体   English

软键盘覆盖editText

[英]SoftKeyboard override editText

I have scrollview with some elements, and one of them - edit text, near the bottom of layout. 我有一些元素的scrollview,其中之一-编辑文本,位于布局底部附近。 when this editText request focus by click - soft keyboard is opened and override that editText fild, so user cant see what he typing... 当单击此editText请求焦点时-打开软键盘并覆盖该editText fild,以便用户看不到他键入的内容...

any ideas why it happen and how to fix it? 有什么想法为什么会发生以及如何解决?

here is my code manifest: 这是我的代码清单:

<activity
            android:name=".acitivity.TransferActivity"
            android:label="@string/title_activity_transfer"
            android:theme="@style/AppTheme.NoActionBar"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="adjustResize">
        </activity>

here is activity xml: 这是活动xml:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    >

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar_transfer"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay" />

    <fragment
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/container_transfer_activity"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:layout="@layout/fragment_transfer" />


</LinearLayout>

here is fragment xml: 这是片段xml:

 <ScrollView
                android:id="@+id/transfer_scroller"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/blue_500"
                xmlns:android="http://schemas.android.com/apk/res/android">
               <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical" >
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical" >
                        //some code here
               </LinearLayout>
               <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical" >
                        //some code here
               </LinearLayout>
               <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical" >
                        <EditText
                            android:id="@+id/et_transfer_p1"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center_horizontal"
                            android:inputType="number"
                            android:textColor="@color/gray_400"
                            android:textSize="@dimen/font_main_2" >
                        </EditText>
               </LinearLayout>
               </LinearLayout>
 </ScrollView>

尝试这个..

android:windowSoftInputMode="adjustPan"
<EditText
        android:id="@+id/et_transfer_p1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
        android:gravity="center_horizontal"
        android:inputType="number"
        android:textColor="@color/gray_400"
        android:textSize="@dimen/font_main_2" />

and set ScrollView height to match_parent 并将ScrollView高度设置为match_parent

Try this to your manifest file: 试试这个到您的清单文件:

<activity
   android:name="com.android.test.ActivityName"
   android:windowSoftInputMode="stateHidden|adjustResize" >
</activity>

simply go to manifest and write this code 只需去清单并编写这段代码

android:windowSoftInputMode="stateVisible|adjustNothing" 机器人:windowSoftInputMode = “stateVisible | adjustNothing”

like this suppose your activity namecom.something.Activity 这样,假设您的活动名称为com.something.Activity

       <activity  android:name="com.something.Activity"

         android:windowSoftInputMode="stateVisible|adjustNothing"
        ></activity>

it will adjust and your textview position will not be changed. 它将调整,并且您的textview位置将不会更改。

在ScrollView中添加,使您可以有效地滚动和键入edittext:

android:fillViewport="true

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

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