键盘重叠Edittext - 活动全屏

时间:2016-08-24 05:34:55

标签: android-edittext android-softkeyboard android-fullscreen

我正在处理聊天应用程序,其中Edittext和send按钮位于底部。 活动是全屏,隐藏导航和状态栏。 当键盘成为焦点时,我需要按下edittext并发送按钮。

以下是我的活动主题和活动中的代码,用于隐藏栏并全屏显示:

 decorView = getWindow().getDecorView();
    uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;

主题:

 <style name="AppTheme_DarkStatus" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryveryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowContentTransitions">true</item>
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>

XMl:

 <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/include_view"
    android:isScrollContainer="true"
    android:background="@android:color/white">

    <com.handmark.pulltorefresh.library.PullToRefreshListView
        xmlns:ptr="http://schemas.android.com/apk/res-auto"
        android:id="@+id/lv_chat"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/rl_send"
        android:divider="@null"
        android:fadeScrollbars="false"
        android:fadingEdge="none"
        android:overScrollMode="never"
        android:scrollbars="none"
        ptr:ptrHeaderSubTextColor="@color/c_input_text_color"
        ptr:ptrHeaderTextColor="@color/c_input_text_color"
        ptr:ptrOverScroll="false"
        ptr:ptrPullLabel="Pull to refresh"
        ptr:ptrRefreshLabel="Loading..."
        ptr:ptrReleaseLabel="Release to refresh"
        ptr:ptrRotateDrawableWhilePulling="true"
        ptr:ptrShowIndicator="false" >
    </com.handmark.pulltorefresh.library.PullToRefreshListView>

    <RelativeLayout
        android:id="@+id/rl_send"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="@color/c_white"
        android:gravity="center" >

        <View
            android:id="@+id/view_dummy"
            android:layout_width="match_parent"
            android:layout_height="@dimen/d_diff_p5dp"
            android:background="@color/c_text_light_color" />

        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/view_dummy"
            android:layout_toLeftOf="@+id/btn_send"
            android:layout_marginRight="@dimen/d_diff_5dp"
            android:layout_marginLeft="@dimen/d_diff_10dp"
            android:layout_marginTop="@dimen/s_diff_7sp"
            android:layout_marginBottom="@dimen/s_diff_7sp"
            android:background="@drawable/opawhite_rectcorner_all" android:id="@+id/relativeLayout">

            <EditText
                android:id="@+id/et_message"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="@dimen/d_diff_1dp"
                android:background="@null"
                android:focusableInTouchMode="true"
                android:maxHeight="100dp"
                android:hint="Type here..."
                android:maxLength="150"
                android:textSize="@dimen/s_diff_16sp"
                android:padding="@dimen/s_diff_6sp"
                android:textColorHint="@color/c_input_text_color"
                android:textColor="@color/c_black" />
        </RelativeLayout>

        <Textview
            android:id="@+id/btn_send"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@color/c_white"
            android:text="Send"
            android:padding="@dimen/d_diff_5dp"
            android:layout_marginRight="@dimen/d_diff_5dp"
            android:gravity="center"
            android:textColor="@color/c_orange_main"
            android:textSize="@dimen/s_diff_16sp"
            android:layout_centerVertical="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentEnd="true"/>
    </RelativeLayout>
</RelativeLayout>

我想在键盘上方显示edittext并发送按钮,但它与edittext重叠。

谢谢!

1 个答案:

答案 0 :(得分:1)

属性android:windowSoftInputMode =“adjustResize”不适用于全屏活动,您必须删除活动全屏标记才能获得调整大小调整的优势。 看到这个: A fullscreen window will ignore a value of SOFT_INPUT_ADJUST_RESIZE for the window's softInputMode field; the window will stay fullscreen and will not resize.

相关问题