工具栏在EditText焦点的键盘启动时向上移动

时间:2016-11-27 02:30:23

标签: android layout keyboard android-toolbar

活动工具栏在键盘启动时向上移动 我的布局有什么问题。

  

尝试过的解决方案:

Android Toolbar moves up when keyboard appears

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:fitsSystemWindows="true"
    android:background="#E0E0E0"
    tools:context="com.moozup.moozup_new.activity.EditMyProfileActivity">

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

        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/Theme.DesignDemo.AppBarOverlay">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar_edit_id"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary">

                <TextView
                    android:id="@+id/text_profile_reset_id"
                    style="?android:actionBarTabTextStyle"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="end"
                    android:layout_marginEnd="40dp"
                    android:drawableLeft="@android:drawable/ic_menu_rotate"
                    android:drawablePadding="8dp"
                    android:gravity="center_vertical"
                    android:paddingLeft="20dp"
                    android:text="Reset" />
            </android.support.v7.widget.Toolbar>

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

        <include layout="@layout/edit_mtprofile_content" />
    </LinearLayout>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab_save_id"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="?attr/selectableItemBackgroundBorderless"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        app:srcCompat="@android:drawable/ic_menu_save" />


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

主要内容在这里:

<?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:card_view="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:paddingLeft="10dp"
    android:paddingRight="10dp"
    android:isScrollContainer="false">

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

        <android.support.v4.widget.Space
            android:layout_width="match_parent"
            android:layout_height="50dp" />

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginBottom="20dp"
            android:layout_gravity="center"
            tools:context=".activity.EditProfileActivity">

            <android.support.v7.widget.CardView
                android:id="@+id/parent_cardView"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginTop="50dp"
                app:cardBackgroundColor="@android:color/white"
                app:cardCornerRadius="@dimen/cardview_default_radius"
                app:cardElevation="4dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_marginEnd="10dp"
                    android:layout_marginStart="10dp"
                    android:layout_marginTop="80dp"
                    android:orientation="vertical">

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

                        <android.support.design.widget.TextInputLayout
                            android:layout_width="160dp"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="8dp"
                            android:layout_marginTop="8dp"
                            android:gravity="center">

                            <EditText
                                android:id="@+id/edit_first_name_id"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:hint="First Name"
                                android:inputType="textPersonName"
                                android:textAppearance="@style/Base.TextAppearance.AppCompat.Body2" />
                        </android.support.design.widget.TextInputLayout>


                        <android.support.design.widget.TextInputLayout
                            android:layout_width="160dp"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="8dp"
                            android:layout_marginTop="8dp"
                            android:gravity="center">

                            <EditText
                                android:id="@+id/edit_last_name_id"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:hint="Last Name"
                                android:inputType="textPersonName"
                                android:textAppearance="@style/Base.TextAppearance.AppCompat.Body2" />
                        </android.support.design.widget.TextInputLayout>

                    </LinearLayout>

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

                        <android.support.design.widget.TextInputLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="8dp"
                            android:layout_marginTop="8dp"
                            android:gravity="center">

                            <EditText
                                android:id="@+id/edit_email_id"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:hint="email"
                                android:inputType="textPersonName"
                                android:textAppearance="@style/Base.TextAppearance.AppCompat.Body2" />
                        </android.support.design.widget.TextInputLayout>
                    </LinearLayout>


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

                        <android.support.design.widget.TextInputLayout
                            android:layout_width="160dp"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="8dp"
                            android:layout_marginTop="8dp"
                            android:gravity="center">

                            <EditText
                                android:id="@+id/edit_designation_id"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:hint="Designation"
                                android:inputType="textPersonName"
                                android:textAppearance="@style/Base.TextAppearance.AppCompat.Body2" />
                        </android.support.design.widget.TextInputLayout>


                        <android.support.design.widget.TextInputLayout
                            android:layout_width="160dp"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="8dp"
                            android:layout_marginTop="8dp"
                            android:gravity="center">

                            <EditText
                                android:id="@+id/edit_company_id"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:hint="Company"
                                android:inputType="textPersonName"
                                android:textAppearance="@style/Base.TextAppearance.AppCompat.Body2" />
                        </android.support.design.widget.TextInputLayout>
                    </LinearLayout>

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

                        <android.support.design.widget.TextInputLayout
                            android:layout_width="160dp"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="8dp"
                            android:layout_marginTop="8dp"
                            android:gravity="center">

                            <EditText
                                android:id="@+id/edit_contact_id"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:hint="Contact"
                                android:inputType="textPersonName"
                                android:textAppearance="@style/Base.TextAppearance.AppCompat.Body2" />
                        </android.support.design.widget.TextInputLayout>


                        <android.support.design.widget.TextInputLayout
                            android:layout_width="160dp"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="8dp"
                            android:layout_marginTop="8dp"
                            android:gravity="center">

                            <EditText
                                android:id="@+id/edit_address_id"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:hint="Address"
                                android:inputType="textPersonName"
                                android:textAppearance="@style/Base.TextAppearance.AppCompat.Body2" />
                        </android.support.design.widget.TextInputLayout>
                    </LinearLayout>

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

                        <android.support.design.widget.TextInputLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="8dp"
                            android:layout_marginTop="8dp"
                            android:gravity="center">

                            <EditText
                                android:id="@+id/edit_description_id"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:hint="About"
                                android:inputType="textPersonName"
                                android:textAppearance="@style/Base.TextAppearance.AppCompat.Body2" />
                        </android.support.design.widget.TextInputLayout>
                    </LinearLayout>


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

                        <android.support.design.widget.TextInputLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="8dp"
                            android:layout_marginTop="8dp"
                            android:gravity="center">

                            <EditText
                                android:id="@+id/edit_talk_id"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:hint="Talk to me"
                                android:inputType="textPersonName"
                                android:textAppearance="@style/Base.TextAppearance.AppCompat.Body2" />
                        </android.support.design.widget.TextInputLayout>
                    </LinearLayout>


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

                        <android.support.design.widget.TextInputLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="8dp"
                            android:layout_marginTop="8dp"
                            android:gravity="center">

                            <EditText
                                android:id="@+id/edit_linked_in_id"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:hint="Linked Url"
                                android:inputType="textPersonName"
                                android:textAppearance="@style/Base.TextAppearance.AppCompat.Body2" />
                        </android.support.design.widget.TextInputLayout>
                    </LinearLayout>

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

                        <android.support.design.widget.TextInputLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="8dp"
                            android:layout_marginTop="8dp"
                            android:gravity="center">

                            <EditText
                                android:id="@+id/edit_facebook_id"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:hint="Twitter Url"
                                android:inputType="textPersonName"
                                android:textAppearance="@style/Base.TextAppearance.AppCompat.Body2" />
                        </android.support.design.widget.TextInputLayout>
                    </LinearLayout>

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

                        <android.support.design.widget.TextInputLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="8dp"
                            android:layout_marginTop="8dp"
                            android:gravity="center">

                            <EditText
                                android:id="@+id/edit_twitter_id"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:hint="Twitter Url"
                                android:inputType="textPersonName"
                                android:textAppearance="@style/Base.TextAppearance.AppCompat.Body2" />
                        </android.support.design.widget.TextInputLayout>
                    </LinearLayout>


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

            <RelativeLayout
                android:id="@+id/prof"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:elevation="10dp">

                <de.hdodenhof.circleimageview.CircleImageView
                    android:id="@+id/circular_edit_image_id"
                    android:layout_width="130dp"
                    android:layout_height="130dp"
                    android:layout_gravity="center_horizontal"
                    android:src="@drawable/user_image"
                    app:finalHeight="@dimen/image_final_width"
                    app:finalYPosition="2dp"
                    app:startHeight="2dp"
                    app:startToolbarPosition="2dp"
                    app:startXPosition="2dp" />

                <android.support.design.widget.FloatingActionButton
                    android:id="@+id/fab_edit_camera_id"
                    android:layout_width="40dp"
                    android:layout_height="40dp"
                    android:layout_alignBottom="@id/circular_edit_image_id"
                    android:layout_alignEnd="@id/circular_edit_image_id"
                    android:scaleType="fitXY"
                    app:fabSize="normal"
                    app:layout_anchorGravity="bottom"
                    app:srcCompat="@drawable/ic_menu_camera" />
            </RelativeLayout>
        </FrameLayout>
    </LinearLayout>
</android.support.v4.widget.NestedScrollView>

布局设计有问题吗? 有什么建议吗?先谢谢。 示例ScreenShot: enter image description here

1 个答案:

答案 0 :(得分:0)

将isScrollContainer设为true

packetizer_h264 warning: waiting for SPS/PPS
core debug: Buffering <some percent>%

希望这会有所帮助:)