键盘出现并调整工具栏大小

时间:2016-02-19 02:30:18

标签: android keyboard toolbar android-custom-view

在使用工具栏而不是Actionbar的许多建议后,我终于做了转换。除了以下问题,一切正常。当用户单击EditText时,工具栏视图会混乱并调整大小。

工具栏在没有键盘的情况下的外观

enter image description here

键盘出现时工具栏的外观

enter image description here

我希望键盘出现时工具栏和键盘都能完全显示。

当我使用ActionBar时,我使用以下设置使其工作 机器人:configChanges = “keyboardHidden |方向|键盘” 机器人:windowSoftInputMode = “adjustResize”

XML

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/CCLL"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:weightSum="1"
    android:background="#F1F1F1"
    android:orientation="vertical">


    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:minHeight="?attr/actionBarSize"
        android:background="#3DA1FE"
        android:fitsSystemWindows="true"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight=".46"
        >



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

    <LinearLayout
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight=".09">

        <ListView
            android:isScrollContainer="false"
            android:stackFromBottom="true"
            android:background="#ffffff"
            android:id="@+id/messagesLV"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_gravity="center_horizontal"
            android:transcriptMode="alwaysScroll"/>

    </LinearLayout>




    <LinearLayout
        android:layout_margin="10dp"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight=".45"
        android:background="@drawable/livefeedgradient"
        android:orientation="horizontal">

        <ImageButton
            android:layout_gravity="center"
            android:id="@+id/addimgbtn"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1.1"
            android:scaleType="centerInside"
            android:background="@null"
            android:src="@mipmap/grayaddimage" />

        <EditText
            android:id="@+id/messageET"
            android:layout_weight=".5"
            android:background="@android:color/transparent"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="10"
            android:lines="5"
            android:gravity="center|left"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:textColor="#000000"
            android:textColorHint="@android:color/darker_gray"
            android:inputType="textCapSentences|textMultiLine"
            android:hint="Enter your Message...">
        </EditText>


        <ImageButton
            android:layout_marginLeft="30dp"
            android:id="@+id/sendbtn"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:scaleType="centerInside"
            android:background="@null"
            android:src="@mipmap/graysend" />

    </LinearLayout>

</LinearLayout>

0 个答案:

没有答案