SoftKeyboard隐藏EditText和Pull ActionBar

时间:2018-05-28 17:55:42

标签: android layout android-softkeyboard

当我点击EditText时,软键盘会显示并隐藏EditText的一小部分并向上推actionBar

尝试过这些事情:

AdjustResize,adjustpan,Adjustresize | adjustpan,fitsystem window 在app栏中设置应用:activity中的layout_collapseMode =“pin”,但无效。

它的外观如下:

NormalState:

enter image description here

错误

enter image description here

点击表情符号时工作

enter image description here

布局在片段内,我必须更改片段布局或活动(容器)布局?

活动布局:

<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:windowSoftInputMode="adjustResize"
android:fitsSystemWindows="true">

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

        <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:id="@+id/toolbar"
        android:layout_height="@dimen/abc_action_bar_default_height_material"
        app:layout_collapseMode="pin"
        app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        app:titleTextAppearance="@style/ToolbarTitleAppearance"
        app:subtitleTextAppearance="@style/ToolbarSubtitleAppearance"
        android:background="#2d5d82"/>

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

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

1 个答案:

答案 0 :(得分:0)

片段布局

  <!--Layout Mensagens-->
        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <!--Geral - Mensagens-->



            <RelativeLayout
                android:id="@+id/relativelayout_chat"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:layout_gravity="top">

                <!--RecycleView Messages-->
                <android.support.v7.widget.RecyclerView
                    android:id="@+id/rv_message"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_above="@+id/typing_Digitando" />

                <!--Indicador Novas Mensagens-->
                <android.support.design.widget.FloatingActionButton
                    android:id="@+id/fab"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentBottom="true"
                    android:layout_alignParentEnd="true"
                    android:layout_marginBottom="80dp"
                    android:layout_marginRight="15dp"
                    android:backgroundTint="#FFFFFF"
                    android:src="@drawable/indicador_msg_whats"
                    android:visibility="visible"
                    app:borderWidth="0dp"
                    app:elevation="5dp"
                    app:fabSize="mini" />

                <FrameLayout
                    android:id="@+id/typing_Digitando"
                    android:layout_width="200dp"
                    android:layout_height="17dp"
                    android:layout_marginStart="10dp"
                    android:layout_marginLeft="10dp"
                    android:layout_above="@+id/typing_frame"
                    android:layout_marginBottom="5dp"
                    android:textAlignment="center"
                    android:visibility="visible">

                    <TextView
                        android:id="@+id/Indicador_acao_amigo"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textStyle="italic"
                        android:singleLine="true"
                        android:text="..."
                        android:textColor="@color/Padrao" />
                </FrameLayout>

                <FrameLayout
                    android:id="@+id/typing_frame"
                    android:layout_width="80dp"
                    android:layout_height="17dp"
                    android:layout_marginStart="10dp"
                    android:layout_marginLeft="10dp"
                    android:layout_above="@+id/bottom_container"
                    android:layout_marginBottom="10dp"
                    android:textAlignment="center"
                    android:visibility="visible">

                    <com.udevel.widgetlab.TypingIndicatorView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:padding="8dp"
                        app:animateFrequency="700"
                        app:animationOrder="lastOneFirst"
                        app:backgroundColor="#eaeaea"
                        app:backgroundType="rounded"
                        app:dotAnimationDuration="600"
                        app:dotAnimationType="Sliding"
                        app:dotColor="#4f7abc"
                        app:dotCount="5"
                        app:dotHorizontalSpacing="4dp"
                        app:dotMaxCompressRatio="70%"
                        app:dotSecondColor="#6b4f7abc"
                        app:dotSize="10dp"
                        app:showBackground="true"/>

                </FrameLayout>

                <!--Container FrameLayout-->
                <FrameLayout
                    android:id="@+id/keyboard_container"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignParentBottom="true"/>

                <!--android:layout_alignParentBottom="true"-->
                <!--Container Emoticon Edittext-->
                <RelativeLayout
                    android:id="@+id/bottom_container"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="@dimen/edt_msg_content_margin"
                    android:layout_marginLeft="@dimen/edt_msg_content_margin"
                    android:layout_marginStart="@dimen/edt_msg_content_margin"
                    android:layout_toLeftOf="@+id/btn_send_message"
                    android:layout_toStartOf="@+id/btn_send_message"
                    android:background="@drawable/message_item_background"
                    android:layout_above="@id/keyboard_container"
                    android:elevation="4dp"
                    android:paddingBottom="@dimen/edt_msg_content_padding_v"
                    android:paddingLeft="@dimen/edt_msg_content_padding_h"
                    android:paddingRight="@dimen/edt_msg_content_padding_h"
                    android:paddingTop="@dimen/edt_msg_content_padding_v">

                    <ImageView
                        android:id="@+id/botao_emoji"
                        android:layout_width="@dimen/edt_ic_size"
                        android:layout_height="@dimen/edt_ic_size"
                        android:layout_alignParentLeft="true"
                        android:layout_alignParentStart="true"
                        android:layout_centerVertical="true"
                        android:background="?attr/selectableItemBackgroundBorderless"
                        android:padding="4dp"
                        app:srcCompat="@drawable/chat_emotions"
                        android:tint="@color/green_600"
                         />

                    <!--<hani.momanii.supernova_emoji_library.Helper.EmojiconEditText-->
                    <com.kevalpatel2106.emoticongifkeyboard.widget.EmoticonEditText
                        android:id="@+id/edt_message_content"
                        style="@style/Base.TextAppearance.AppCompat.Medium"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_toLeftOf="@+id/iv_camera"
                        android:layout_toStartOf="@+id/iv_camera"
                        android:background="#00ffffff"
                        android:hint="Digite sua mensagem!"
                        android:inputType="textMultiLine|textCapSentences|textNoSuggestions"
                        android:lines="2"
                        android:maxLines="40"
                        android:imeOptions="flagNoFullscreen"
                        android:layout_toRightOf="@+id/botao_emoji"
                        android:layout_toEndOf="@+id/botao_emoji"/>

                    <ImageButton
                        android:id="@+id/message_love_button"
                        android:layout_width="@dimen/edt_ic_size"
                        android:layout_height="@dimen/edt_ic_size"
                        android:layout_alignParentEnd="true"
                        android:layout_alignParentRight="true"
                        android:layout_centerVertical="true"
                        android:background="?attr/selectableItemBackgroundBorderless"
                        android:padding="4dp"
                        app:srcCompat="@drawable/ic_love_animation"
                        android:tint="@color/red_400"/>

                </RelativeLayout>


                <!--android:layout_alignParentBottom="true"-->
                <!--Enviar mensagem floatingbutton-->
                <android.support.design.widget.FloatingActionButton
                    android:id="@+id/btn_send_message"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"

                    android:layout_alignParentEnd="true"
                    android:layout_alignParentRight="true"
                    android:layout_above="@id/keyboard_container"
                    app:backgroundTint="@color/Padrao"
                    android:layout_gravity="bottom|end"
                    android:layout_margin="@dimen/fab_send_margin"
                    app:srcCompat="@drawable/ic_send"
                    android:text="@string/button_send"
                    app:pressedTranslationZ="10dp"/>

            </RelativeLayout>



            </FrameLayout>