出现虚拟键盘时,在NestedScrollView中向上移动EditText

时间:2015-11-18 09:28:00

标签: android xml android-edittext scrollview virtual-keyboard

我知道此问题之前曾被问过,但不幸的是,所有解决方案对我都没有用。

android:windowSoftInputMode="stateAlwaysHidden|adjustResize|adjustPan"activityRootView.getViewTreeObserver().addOnGlobalLayoutListener()

当我调用虚拟键盘时,它出现在EditText上,我无法看到我输入的内容。

我的布局:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView 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:background="@android:color/darker_gray"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:showIn="@layout/activity_scrolling">

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

        <android.support.v7.widget.CardView
            style="@style/CardViewSection"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:cardCornerRadius="@dimen/card_corner_radius">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginTop="@dimen/standard_margin"
                android:orientation="vertical">

                <TextView
                    style="@style/HeaderTextView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/header_input_awb_no" />

                <RadioGroup
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:orientation="horizontal"
                    android:paddingLeft="30dp"
                    android:paddingTop="@dimen/standard_margin">

                    <RadioButton
                        android:id="@+id/ownAwb"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:text="@string/own_awb_no" />

                    <RadioButton
                        android:id="@+id/nextAvailable"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:text="@string/next_available" />

                    <RadioButton
                        android:id="@+id/useOwn"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:text="@string/use_own_stock" />
                </RadioGroup>

                <EditText
                    android:id="@+id/awbNo"
                    style="@style/EditTextChooser"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="@dimen/standard_margin"
                    android:cursorVisible="true"
                    android:hint="@string/prompt_awn_no" />

                <Button
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="@dimen/small_margin"
                    android:background="@drawable/ripple"
                    android:paddingBottom="30dp"
                    android:paddingTop="30dp"
                    android:text="@string/action_check"
                    android:textColor="@android:color/white" />

            </LinearLayout>
        </android.support.v7.widget.CardView>

        <android.support.v7.widget.CardView
            style="@style/CardViewSection"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:cardCornerRadius="@dimen/card_corner_radius">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginTop="@dimen/standard_margin"
                android:orientation="vertical">

                <TextView
                    style="@style/HeaderTextView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/header_date_shipment_ready" />

                <EditText
                    android:id="@+id/dateChooser"
                    style="@style/EditTextChooser"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/prompt_choose_date" />

            </LinearLayout>
        </android.support.v7.widget.CardView>

        <android.support.v7.widget.CardView
            style="@style/CardViewSection"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:cardCornerRadius="@dimen/card_corner_radius">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginTop="@dimen/standard_margin"
                android:orientation="vertical">

                <TextView
                    style="@style/HeaderTextView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/header_airport_departure" />

                <EditText
                    android:id="@+id/departureAirportChooser"
                    style="@style/EditTextChooser"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/prompt_select_airport"
                    android:inputType="textNoSuggestions" />

                <TextView
                    style="@style/HeaderTextView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/header_airport_departure" />

                <EditText
                    android:id="@+id/destinationAirportChooser"
                    style="@style/EditTextChooser"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/prompt_destination_cargo"
                    android:inputType="textNoSuggestions" />

                <TextView
                    style="@style/HeaderTextView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/header_hawb" />

                <EditText
                    android:id="@+id/hawb"
                    style="@style/EditTextChooser"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:cursorVisible="true"
                    android:hint="@string/prompt_select_hawb"
                    android:inputType="textNoSuggestions" />

                <TextView
                    style="@style/HeaderTextView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/header_hawb_origin" />

                <EditText
                    android:id="@+id/hawbOrigin"
                    style="@style/EditTextChooser"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/prompt_select_airport"
                    android:inputType="textNoSuggestions" />

            </LinearLayout>
        </android.support.v7.widget.CardView>

        <android.support.v7.widget.CardView
            style="@style/CardViewSection"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:cardCornerRadius="@dimen/card_corner_radius">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginTop="@dimen/standard_margin"
                android:orientation="vertical">

                <TextView
                    style="@style/HeaderTextView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/header_total_gross_weight" />

                <EditText
                    android:id="@+id/totalGrossWeight"
                    style="@style/EditTextChooser"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:cursorVisible="true"
                    android:hint="@string/prompt_total_gross_weight" />

                <TextView
                    style="@style/HeaderTextView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/header_quotation_ref_num" />

                <EditText
                    android:id="@+id/quotationNumber"
                    style="@style/EditTextChooser"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:cursorVisible="true" />

                <TextView
                    style="@style/HeaderTextView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/header_cargo_description" />

                <EditText
                    android:id="@+id/cargoDescription"
                    style="@style/EditTextChooser"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:cursorVisible="true"
                    android:hint="@string/prompt_describe_your_cargo" />

                <TextView
                    style="@style/HeaderTextView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/header_destination_place" />

                <EditText
                    android:id="@+id/destinationPlace"
                    style="@style/EditTextChooser"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:cursorVisible="true"
                    android:hint="@string/prompt_destination_place" />

            </LinearLayout>
        </android.support.v7.widget.CardView>

        <android.support.v7.widget.CardView
            style="@style/CardViewSection"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:cardCornerRadius="@dimen/card_corner_radius">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginTop="@dimen/standard_margin"
                android:orientation="vertical">

                <TextView
                    style="@style/HeaderTextView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/header_shipper" />

                <EditText
                    android:id="@+id/shipper"
                    style="@style/EditTextMultiline"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/header_shipper" />

            </LinearLayout>
        </android.support.v7.widget.CardView>
    </LinearLayout>


</android.support.v4.widget.NestedScrollView>

我的清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="ua.pp.ssidit">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".view.LoginActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".view.ScrollingActivity"
            android:label="@string/title_activity_scrolling"
            android:theme="@style/AppTheme.NoActionBar"
            android:windowSoftInputMode="stateAlwaysHidden|adjustResize|adjustPan"></activity>
    </application>

</manifest>

0 个答案:

没有答案
相关问题