简体   繁体   English

Android:软件键盘与按钮重叠

[英]Android: The software keyboard overlaps the button

I made a form with a EditText and a button at the bottom of form. 我在表单底部创建了一个带有EditText和按钮的表单。 If you put the focus on EditText keyboard appears which overlaps the button. 如果您将焦点放在EditText键盘上,则会出现与按钮重叠的键盘。 Windows soft input mode: stateHidden|adjustPan. Windows软输入模式:stateHidden | adjustPan。 Is there any way to make the keyboard do not overlap button? 有没有办法让键盘不重叠按钮?

Screenshot1 http://i1204.photobucket.com/albums/bb408/krestor85/screen1_zpsjfmdlp9d.jpg 截图1 http://i1204.photobucket.com/albums/bb408/krestor85/screen1_zpsjfmdlp9d.jpg

Screenshot2 http://i1204.photobucket.com/albums/bb408/krestor85/screen2_zpszy97utxy.jpg 截图2 http://i1204.photobucket.com/albums/bb408/krestor85/screen2_zpszy97utxy.jpg

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/login_bg"
    android:orientation="vertical" >

    <FrameLayout
        android:id="@+id/statusBar"
        android:layout_width="match_parent"
        android:layout_height="@dimen/albumstatusBarHeight"
        android:background="?colorPrimaryDark"
        android:translationZ="4dp" />

    <android.support.v7.widget.Toolbar
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minHeight="?attr/actionBarSize"   
        style="@style/ToolBarStyle.Event"
        app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"     
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        android:background="@android:color/transparent"/>

   <TextView 
       android:id="@+id/welcomeTxt"
       android:text="@string/welcome"
       style="@style/welcomeLabel"
       >
   </TextView>
   <ImageView
       android:id="@+id/logoApp"
       android:src="@drawable/logo"
       style="@style/logoImage">
   </ImageView>

   <TextView 
       android:id="@+id/verificationTxt"
       android:text="@string/verification_text"
       style="@style/VerificationTextStyle"
       android:layout_marginTop="27dp"
       >
   </TextView>

   <RelativeLayout
       android:layout_marginTop="16dp"
       android:id="@+id/countryField"
       style="@style/VerificationFieldsStyle"
       >       
       <TextView 
           android:id="@+id/countryTxtView"
           style="@style/VerificationTextFieldsStyle"
           android:layout_alignParentLeft="true"
           android:text="@string/country_text"/>
       <LinearLayout 
            android:layout_alignParentRight="true"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="horizontal"
            >
              <TextView 
                 android:id="@+id/countryNameView"
                 style="@style/VerificationTextFieldsStyle"
                 android:layout_marginRight="10dp"
                 android:text="@string/country_example"/>
              <ImageView
                  android:id="@+id/moreImage"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_marginRight="10dp"
                  android:src="@drawable/more"
                  android:layout_gravity="center"/>

        </LinearLayout>
   </RelativeLayout>

   <ImageView
       android:src="@drawable/vertical_divider_shape"
       android:layout_width="match_parent"
       android:layout_height="1px"
       android:layout_marginLeft="10dp"
       android:layout_marginRight="10dp"/>

   <RelativeLayout
       android:id="@+id/phoneField"
       style="@style/VerificationFieldsStyle"
       android:background="@drawable/verification_background_bottom"
       >       
       <LinearLayout 
            android:id="@+id/phoneCodeLayout"
            android:layout_alignParentLeft="true"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="horizontal"
            >
            <TextView 
                 android:id="@+id/countryPhoneCodeView"
                 style="@style/VerificationTextFieldsStyle"           
                 android:text="@string/country_phone_code_example"
             />
            <ImageView
                android:layout_width="2dp"
                android:layout_height="match_parent"
                android:layout_marginTop="5dp"
                android:layout_marginBottom="5dp"
                android:src="@drawable/vertical_divider_shape"
                />
        </LinearLayout>
        <EditText 
                 android:id="@+id/countryPhoneView"
                 style="@style/VerificationEditPhoneText"  
                 android:inputType="phone"                 
                 android:layout_toRightOf="@+id/phoneCodeLayout"
                 android:layout_alignParentRight="true"     
             />
   </RelativeLayout>

   <Button
       android:id="@+id/loginButton"
       style="@style/LoginButtonStyle"
       android:layout_marginTop="34dp"
       android:text="@string/login_button_text"
       android:textColorLink="@color/login_color" />

</LinearLayout>

Try adding: 尝试添加:

android:windowSoftInputMode="adjustPan|adjustResize"

to your activity tag. 到你的活动标签。

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

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