当键盘显示时,使用RecyclerView的LinearLayout会缩小?

时间:2017-12-18 11:57:06

标签: android

嗨我有一个带有一个底视图的两个recyclerView。当我点击recyclerView中的一个项目时,应该会出现一个带有editText的弹出窗口。当我触摸editText触发键盘时,线性布局会被推高。我不想推高键盘在屏幕上方可见的布局。

XML代码

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:isScrollContainer="false">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/relative_layout"
        android:orientation="vertical">

        <include layout="@layout/app_toolbar" />

        <View
            android:layout_width="match_parent"
            android:layout_height="@dimen/margin_1dp"
            android:background="@color/black_color_10_percent" />

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/black_color_2_percent">

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

                <RelativeLayout
                    android:id="@+id/tool_tip_layout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_vertical"
                    android:background="@color/color_white"
                    android:gravity="center_vertical"
                    android:padding="5dp">

                    <TextView
                        android:id="@+id/text_view_user_tool_tip_label"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_centerVertical="true"
                        android:layout_marginLeft="@dimen/margin_10dp"
                        android:layout_toLeftOf="@+id/image_view_remove_tool_tip"
                        android:gravity="center|left"
                        android:singleLine="true"
                        android:textColor="@color/icon_un_selected_color"
                        android:textSize="@dimen/text_size_12dp" />

                    <ImageView
                        android:id="@+id/image_view_remove_tool_tip"
                        android:layout_width="@dimen/margin_24dp"
                        android:layout_height="@dimen/margin_24dp"
                        android:layout_alignParentRight="true"
                        android:layout_gravity="right|center_vertical"
                        android:layout_marginRight="@dimen/margin_10dp"
                        android:background="@drawable/circle_grey_bg"
                        android:padding="@dimen/margin_6dp"
                        android:src="@drawable/ic_close_white_24dp" />

                </RelativeLayout>

                <android.support.v7.widget.CardView
                    android:id="@+id/card_view_your_suggestions"
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="2"
                    app:cardBackgroundColor="@color/light_grey_color"
                    app:cardCornerRadius="0dp"
                    app:cardElevation="0.5dp"
                    app:cardMaxElevation="1dp"
                    app:cardPreventCornerOverlap="true"
                    app:cardUseCompatPadding="true"
                    app:contentPaddingBottom="0dp">

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

                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="@dimen/margin_40dp"
                            android:background="@color/color_grey"
                            android:gravity="center|left"
                            android:paddingLeft="@dimen/margin_12dp"
                            android:text="@string/text_your_selections"
                            android:textColor="@color/black_color_87_percent"
                            android:textSize="@dimen/text_size_14dp" />

                        <android.support.v7.widget.RecyclerView
                            android:id="@+id/recycler_view_your_selection_list"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:scrollbars="none" />

                    </LinearLayout>

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

                <android.support.v7.widget.CardView
                    android:id="@+id/card_view_suggestions"
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_marginTop="@dimen/margin_6dp"
                    android:layout_weight="3"
                    android:background="@android:color/white"
                    app:cardCornerRadius="0dp"
                    app:cardElevation="0dp"
                    app:cardMaxElevation="1dp"
                    app:cardPreventCornerOverlap="true"
                    app:cardUseCompatPadding="true"
                    app:contentPaddingBottom="0dp">

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

                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="@dimen/margin_40dp"
                            android:background="@color/color_grey"
                            android:gravity="center|left"
                            android:paddingLeft="@dimen/margin_12dp"
                            android:text="@string/text_your_suggestions"
                            android:textColor="@color/black_color_87_percent"
                            android:textSize="@dimen/text_size_14dp" />

                        <android.support.v7.widget.RecyclerView
                            android:id="@+id/recycler_view_your_suggestion_list"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:background="@android:color/white"
                            android:fadeScrollbars="false"
                            android:scrollbarThumbVertical="@drawable/scrollbar_thumb"
                            android:scrollbarTrackVertical="@drawable/scrollbar_track"
                            android:scrollbars="vertical" />

                    </LinearLayout>

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

                <android.support.v7.widget.CardView
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_marginTop="@dimen/margin_8dp"
                    android:layout_weight="1.1"
                    android:visibility="gone"
                    app:cardBackgroundColor="@color/light_grey_color"
                    app:cardCornerRadius="0dp"
                    app:cardElevation="0dp"
                    app:cardMaxElevation="1dp"
                    app:cardPreventCornerOverlap="true"
                    app:cardUseCompatPadding="true"
                    app:contentPaddingBottom="0dp">

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

                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="@dimen/margin_40dp"
                            android:background="@color/colorPrimaryDark"
                            android:gravity="center|left"
                            android:paddingLeft="@dimen/margin_12dp"
                            android:text="@string/text_add_new"
                            android:textColor="@color/black_color_87_percent"
                            android:textSize="@dimen/text_size_14dp" />

                        <abihealth.emrappabi.widgets.MyCustomTextView
                            android:id="@+id/text_view_add_new_element"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_margin="@dimen/margin_8dp"
                            android:background="@drawable/edit_text_bg"
                            android:maxLines="1"
                            android:paddingLeft="@dimen/margin_8dp" />

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

    <RelativeLayout
        android:id="@+id/relative_layout"
        android:layout_width="match_parent"
        android:layout_height="@dimen/margin_40dp"
        android:layout_alignParentBottom="true"
        android:background="@color/color_grey">

        <LinearLayout
            android:id="@+id/add_new_phrase_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="@dimen/margin_6dp"
            android:background="@android:color/white"
            android:gravity="center_vertical"
            android:orientation="horizontal">

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="@dimen/margin_6dp"
                android:src="@drawable/icon_add_drawable" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center|left"
                android:paddingLeft="@dimen/margin_2dp"
                android:text="@string/text_add_phrase"
                android:textColor="@color/black_54_percent"
                android:textSize="@dimen/text_size_14dp" />

        </LinearLayout>
    </RelativeLayout>
</RelativeLayout>

Layout should not pushed up

1 个答案:

答案 0 :(得分:0)

添加到您在manifest中的活动,这对我有用

<activity
   ...
  android:windowSoftInputMode="adjustNothing"> 
</activity>