我的应用程序在键盘

时间:2018-02-26 10:56:24

标签: android android-softkeyboard

我的应用程序在键盘下显示空白区域。 当我单击edittext框时,它会显示软键盘(系统默认值),但在键盘下显示一些空白区域。

我的屏幕是5.5"和型号是华硕Zenfone与Android 6.0.1

这是我的AndroidManifest.xml文件

<activity
        android:name=".Activity.LoginActivity"
        android:windowSoftInputMode="stateHidden" />

我的Layout.xml文件是

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/llParent"
    android:orientation="vertical">

    <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/appbarLayout"
        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:fitsSystemWindows="true">

        <android.support.design.widget.AppBarLayout
            android:id="@+id/appbar"
            android:layout_width="match_parent"
            android:layout_height="@dimen/capacities_list_actionbar_height"
            android:fitsSystemWindows="true"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

            <android.support.design.widget.CollapsingToolbarLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                app:collapsedTitleTextAppearance="@style/CapacitiesCollapsedAppBar"
                app:contentScrim="?attr/colorPrimary"
                app:expandedTitleMarginBottom="@dimen/capacities_list_expandedtitle_margin_bottom"
                app:scrimAnimationDuration="70"
                app:expandedTitleTextAppearance="@style/CapacitiesExpandedAppBar"
                app:layout_scrollFlags="scroll|exitUntilCollapsed"
                app:title="Login">
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:fitsSystemWindows="true"
                    android:orientation="vertical">

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_alignParentBottom="true"
                        android:textSize="@dimen/capacities_list_subtitle_text_size"
                        android:lines="2"
                        android:layout_marginTop="@dimen/capacities_list_subtitle_bottom_margin"
                        android:layout_marginLeft="@dimen/capacities_list_subtitle_left_margin"
                        android:text="@string/login_to_the_capacity_owner_s_app"
                        android:textColor="@color/color_white_light"
                        android:layout_marginStart="@dimen/capacities_list_subtitle_left_margin" />

                </RelativeLayout>

                <android.support.v7.widget.Toolbar
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    app:layout_collapseMode="pin"
                    app:popupTheme="@style/ThemeOverlay.AppCompat.Light">

                    <TextView
                        android:id="@+id/lblSignup"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="end"
                        android:layout_marginEnd="@dimen/login_signup_button_margin"
                        android:layout_marginRight="@dimen/login_signup_button_margin"
                        android:padding="10dp"
                        android:text="@string/sign_up"
                        android:textAllCaps="true"
                        android:textColor="@color/color_white"
                        android:textSize="@dimen/login_login_button_text_size" />

                </android.support.v7.widget.Toolbar>

            </android.support.design.widget.CollapsingToolbarLayout>

        </android.support.design.widget.AppBarLayout>



        <android.support.v4.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/color_white"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_behavior="@string/appbar_scrolling_view_behavior">
                <View
                    android:layout_width="match_parent"
                    android:layout_height="7dp"
                    android:background="@drawable/style_header_shadow"/>
                <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"
                        android:padding="@dimen/login_linearlayout_padding">

                        <RelativeLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="@dimen/login_space_margin">

                            <LinearLayout
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:orientation="vertical">

                                <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:text="@string/email"
                                    android:textColor="@color/color_black"
                                    app:font_style="BOLD"
                                    android:layout_marginLeft="@dimen/_3sdp"
                                    android:textSize="@dimen/_12sdp" />

                                <EditText
                                    android:id="@+id/txtLoginEmail"
                                    android:layout_width="match_parent"
                                    android:layout_height="wrap_content"
                                    android:hint="e.g. johdoe@xyz.com"
                                    android:textColor="@color/color_black"
                                    android:textColorHint="@color/color_dul"
                                    android:background="#fff"
                                    android:paddingTop="5dp"
                                    android:paddingLeft="5dp"
                                    android:paddingRight="5dp"
                                    android:paddingBottom="5dp"
                                    android:inputType="textEmailAddress"
                                    android:textSize="@dimen/login_edittext_text_size" />
                            </LinearLayout>


                            <ImageView
                                android:id="@+id/imgLoginRightSign"
                                android:layout_width="@dimen/login_right_sign_image_width"
                                android:layout_height="@dimen/login_right_sign_image_hight"
                                android:layout_alignParentEnd="true"
                                android:layout_alignParentRight="true"
                                android:layout_marginEnd="@dimen/login_right_sign_image_right_margin"
                                android:layout_marginRight="@dimen/login_right_sign_image_right_margin"
                                android:layout_marginTop="@dimen/login_right_sign_image_top_margin"
                                android:background="@drawable/right_sign_green_icon"
                                android:visibility="visible" />

                            <View
                                android:id="@+id/viewEmailLine"
                                android:layout_width="match_parent"
                                android:layout_height="2dp"
                                android:layout_marginLeft="5dp"
                                android:layout_alignParentBottom="true"
                                android:background="#909090"/>
                        </RelativeLayout>
                        <TextView
                            android:id="@+id/lblEmailErrorMessage"
                            android:layout_width="match_parent"
                            android:layout_marginTop="5dp"
                            android:layout_height="wrap_content"
                            android:textColor="@color/line_error_color"
                            android:paddingLeft="5dp"
                            android:text=""/>

                        <RelativeLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="@dimen/login_space_margin">

                            <LinearLayout
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:orientation="vertical">

                                <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:text="@string/password"
                                    android:textColor="@color/color_black"
                                    app:font_style="BOLD"
                                    android:layout_marginLeft="@dimen/_3sdp"
                                    android:textSize="@dimen/_12sdp" />

                                <EditText
                                    android:id="@+id/txtLoginPassword"
                                    android:layout_width="match_parent"
                                    android:layout_height="wrap_content"
                                    android:hint="e.g.***********"
                                    android:background="#fff"
                                    android:textColor="@color/color_black"
                                    android:textColorHint="@color/color_dul"
                                    android:paddingTop="5dp"
                                    android:paddingLeft="5dp"
                                    android:paddingRight="5dp"
                                    android:paddingBottom="5dp"
                                    android:inputType="textPassword"
                                    android:maxLength="12"
                                    android:textSize="@dimen/login_edittext_text_size" />
                            </LinearLayout>

                            <android.support.design.widget.TextInputLayout
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content">


                            </android.support.design.widget.TextInputLayout>

                            <ImageView
                                android:visibility="gone"
                                android:id="@+id/imgLoginEyeIcon"
                                android:layout_width="@dimen/signup_eye_image_width"
                                android:layout_height="@dimen/signup_eye_image_hight"
                                android:layout_alignParentEnd="true"
                                android:layout_alignParentRight="true"
                                android:layout_marginEnd="@dimen/signup_eye_image_right_margin"
                                android:layout_marginRight="@dimen/signup_eye_image_right_margin"
                                android:layout_marginTop="@dimen/signup_eye_image_top_margin"
                                android:background="@drawable/eye_visible" />

                            <View
                                android:id="@+id/viewPasswordLine"
                                android:layout_width="match_parent"
                                android:layout_height="2dp"
                                android:layout_marginLeft="5dp"
                                android:layout_alignParentBottom="true"
                                android:background="#909090"/>
                        </RelativeLayout>

                        <TextView
                            android:id="@+id/lblPasswdErrorMessage"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="5dp"
                            android:textColor="@color/line_error_color"
                            android:paddingLeft="5dp"
                            android:paddingStart="5dp" />

                        <Button
                            android:id="@+id/btnLogin"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="@dimen/login_space_margin"
                            android:gravity="center"
                            android:padding="@dimen/login_next_button_padding"
                            android:text="@string/login"
                            android:textSize="@dimen/login_next_button_text_size" />

                    </LinearLayout>

                    <TextView
                        android:id="@+id/lblForgotPassword"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:gravity="center"
                        android:textStyle="bold"
                        android:layout_marginTop="25dp"
                        android:text="@string/forgot_password"
                        android:textColor="@color/color_dark_blue"
                        android:textSize="@dimen/login_forgot_password_button_text_size" />
                </LinearLayout>
            </RelativeLayout>
        </android.support.v4.widget.NestedScrollView>
    </android.support.design.widget.CoordinatorLayout>
</LinearLayout>

我附上了键盘问题的截图。

1 个答案:

答案 0 :(得分:0)

之所以发生这种情况,是因为您使用了 NestedScrollView 这与行为app:layout_behavior="@string/appbar_scrolling_view_behavior"的完整高度不匹配,这种行为使得底部布局与AppBarLayout的底部相连接。

注意:如果您要滚动内容,则需要使用 NestedScrollView

否则:键盘应位于底部,因此此问题可能仅在您的设备中。