软键盘的问题隐藏了一些字段

时间:2019-02-28 07:25:42

标签: android android-layout scroll keyboard

打开键盘并隐藏edittext和按钮并且没有滚动时,我遇到问题。 我在互联网上搜索,找到了一些解决方案,例如添加到AndroidManifest.xml android:windowSoftInputMode="stateHidden|adjustResize"ScrollView顶部(位于Login_Activity.xml的顶部)甚至fillViewport="true"上,但它们都不适合我。< / p>

我的活动上有TabLayout,在TabLayout中,我有Login_Fragment.xml,并且其中有editText字段。 这是我的代码:

清单:

        <activity
        android:name="com.ideomobile.common.ui.custom.WebViewActivity"
        android:configChanges="orientation|keyboardHidden"
        android:label="@string/app_name"
        android:launchMode="singleTask"
        android:screenOrientation="portrait" />

Login_Activity.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical"
android:weightSum="10">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="2"
    android:background="@color/BackgroundColor"
    android:layoutDirection="rtl"
    android:orientation="horizontal">

    <ImageButton
        android:id="@+id/imageButton_Info"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_gravity="right|center_vertical"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:background="@drawable/info_button"
        android:clickable="true"
        android:paddingRight="10dp" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_gravity="center"
        android:background="@drawable/logo" />
</RelativeLayout>

<android.support.design.widget.TabLayout

    android:id="@+id/sliding_tabs"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_gravity="bottom"
    android:layout_weight="1.5"
    android:background="@color/BackgroundColor"
    android:layoutDirection="rtl"
    android:textColor="@color/finger_print_blue"
    app:tabBackground="@drawable/tab_indicator_color"
    app:tabGravity="fill"
    app:tabIndicatorColor="@color/popups_blue_background"
    app:tabIndicatorFullWidth="false"
    app:tabMode="fixed" />


<android.support.v4.view.ViewPager
    android:id="@+id/viewpager"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_gravity="fill"
    android:layout_marginBottom="0dp"
    android:layout_weight="6.5"
    android:background="@android:color/white"
    android:paddingBottom="0dp" />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:background="@color/white"
    android:gravity="center|bottom"
    android:orientation="vertical">

    <Button
        android:id="@+id/buttonLogin"
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:layout_gravity="center_horizontal|center"
        android:background="@color/login_button_disable"
        android:enabled="false"
        android:text="@string/login_button"
        android:textAlignment="center"
        android:textColor="@color/BackgroundColor"
        android:textSize="11pt"
        android:textStyle="bold" />

</LinearLayout>

Login_Fragment.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="wrap_content"
android:background="@color/BackgroundColor"
android:orientation="vertical"
android:textDirection="rtl">

<LinearLayout
    android:id="@+id/lines_for_finger_print"
    android:layout_width="match_parent"
    android:layout_height="80dp"
    android:gravity="center"
    android:orientation="vertical">

    <TextView
        android:id="@+id/finger_print_firat_line"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:layout_marginTop="20dp"
        android:gravity="center"
        android:text="@string/add_fingerprint_title_line_1"
        android:textColor="@color/finger_print_blue"
        android:textSize="11pt"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/finger_print_second_line"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:gravity="center"
        android:text="@string/add_finger_print_title_line_2"
        android:textColor="@color/text_login_fields"
        android:textSize="8pt" />
</LinearLayout>

<EditText
    android:id="@+id/editTextUserName"
    android:layout_width="match_parent"
    android:layout_height="60dp"
    android:layout_margin="20dp"
    android:background="@drawable/edit_text_border"
    android:cursorVisible="false"
    android:digits="@string/fingerprint_digits_allows"
    android:gravity="right|center_vertical"
    android:hint="@string/user_name"
    android:imeOptions="actionNext"
    android:inputType="text"
    android:textColor="@color/text_login_fields"
    android:textColorHint="@color/text_login_fields"
    android:textSize="11pt"
    android:singleLine="true"/>

<EditText
    android:id="@+id/editTextPassword"
    android:layout_width="match_parent"
    android:layout_height="60dp"
    android:layout_marginLeft="20dp"
    android:layout_marginRight="20dp"
    android:background="@drawable/edit_text_border"
    android:digits="@string/fingerprint_digits_allows"
    android:gravity="right|center_vertical"
    android:hint="@string/user_password"
    android:imeOptions="actionNext"
    android:inputType="textPassword"
    android:paddingRight="20dp"
    android:textColorHint="@color/text_login_fields"
    android:textSize="11pt"
    android:singleLine="true"/>


<TextView
    android:id="@+id/textViewforgotPassword"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="20dp"
    android:gravity="center"
    android:linksClickable="true"
    android:text="@string/link_forgot_password"
    android:textAlignment="center"
    android:textColor="@color/finger_print_blue"
    android:textSize="7pt" />

需要提及的是,没有键盘时无需滚动。仅在键盘打开时才需要滚动。

你能帮我解决吗?

1 个答案:

答案 0 :(得分:0)

尝试使用 windowSoftInputMode

  <application
        android:hardwareAccelerated="true"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:windowSoftInputMode="adjustPan"
        android:theme="@style/AppTheme">
    <activity android:name=".Activity.LoginActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
    </application>