当EditText聚焦时,使用TextInputLayout滚动NestedScrollView

时间:2015-12-29 13:19:49

标签: android nestedscrollview textinputlayout

我有那个布局:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    android:id="@+id/coordinatorLayout"
    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:background="@color/appbar_background">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="360dp"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        app:elevation="1dp">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:minHeight="?attr/actionBarSize"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:titleEnabled="false">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_collapseMode="parallax"
                app:layout_collapseParallaxMultiplier="0.7">

                <android.support.v4.view.ViewPager
                    android:id="@+id/post_pager"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                />

            </RelativeLayout>

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


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


    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="16dp"
        android:background="@color/common_green"
        android:src="@drawable/add_picture"
        app:backgroundTint="@color/common_green"
        app:elevation="2dp"
        app:fabSize="normal"
        app:layout_anchor="@id/appbar"
        app:layout_anchorGravity="bottom|left|start"
        app:rippleColor="@color/common_grey"/>


    <android.support.v4.widget.NestedScrollView
        android:id="@+id/nested_scroll"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="fill_vertical"
        android:fitsSystemWindows="true"
        android:padding="16dp"
        app:elevation="5dp"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

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

            <android.support.design.widget.TextInputLayout
                android:id="@+id/slide_content_til"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:background="@color/appbar_background"
                android:hint="@string/write_something"
                android:orientation="vertical"
                android:textColorHint="@color/white"
                app:errorEnabled="false"
                app:hintAnimationEnabled="false"
                app:hintTextAppearance="@style/TextAppearanceDesignHint">

                <EditText
                    android:id="@+id/slide_content_edt"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:focusable="true"
                    android:focusableInTouchMode="true"
                    android:hint="@string/write_something"
                    android:imeOptions="actionDone"
                    app:backgroundTint="@color/common_blue"
                />
            </android.support.design.widget.TextInputLayout>
        </LinearLayout>

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

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

我在清单中的那项活动 机器人:windowSoftInputMode = “stateAlwaysHidden | adjustResize”

但是当我点击EditText并且它被聚焦时(键盘打开)NestedScrollView不会向上滚动而EditText被键盘覆盖 如何让它向上滚动?

0 个答案:

没有答案