使用windowSoftInputMode="adjustPan"隐藏ActionBar并调整布局大小

4
在一个聊天应用程序中,我有一个带有图像背景的活动。现在当我输入要发布的消息时,手机键盘会出现并使我的布局缩小,如果我在清单文件中使用windowSoftInputMode="adjustResize"。另外,当我使用windowSoftInputMode="adjustPan"时,手机键盘将隐藏操作栏。这两个问题在市场上许多应用程序中都得到了巧妙的解决,例如WhatsApp聊天。请帮助我解决我的应用程序中的这个问题。以下是我的聊天活动布局。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/chat_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:weightSum="11"
    tools:context="com.sixsquarekik.app.ChatActivity" >

    <LinearLayout
        android:id="@+id/setFrameLayout"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="9"
        android:isScrollContainer="false"
        android:padding="5dip" >

        <android.support.v4.widget.SwipeRefreshLayout
            android:id="@+id/activity_main_swipe_refresh_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <ListView
                android:id="@+id/mlistView"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_alignParentTop="true"
                android:background="@android:color/transparent"
                android:cacheColorHint="@android:color/transparent" >
            </ListView>
        </android.support.v4.widget.SwipeRefreshLayout>
    </LinearLayout>

    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="@color/ColorPrimary" />

    <LinearLayout
        android:id="@+id/chat_window_layout"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="2"
        android:gravity="center_horizontal"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="5dp"
            android:layout_weight="1"
            android:background="@color/White"
            android:gravity="center_horizontal"
            android:isScrollContainer="false"
            android:orientation="horizontal"
            android:weightSum="5" >

            <EditText
                android:id="@+id/mEditText1"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="4"
                android:background="#00000000"
                android:ems="10"
                android:paddingBottom="2dp"
                android:hint="Message here"
                android:paddingTop="5dp" >

                <requestFocus />
            </EditText>

            <ImageButton
                android:id="@+id/mButton"
                style="?android:attr/buttonStyleSmall"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@android:color/transparent"
                android:onClick="onSendMessage"
                android:src="@drawable/ic_action_send_now"
                android:text="send" />
        </LinearLayout>
    </LinearLayout>

</LinearLayout>

你有得到任何答案吗? - Deep Dave
1个回答

0

您可以创建一个 XML 位图并将其用作视图的背景。为了防止拉伸,您可以指定 android:gravity 属性。

例如:

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/dvdr"
    android:tileMode="disabled" android:gravity="top" >
</bitmap>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接