簡體   English   中英

使用windowSoftInputMode =“adjustPan”隱藏動作欄並調整resize縮小布局

[英]Using windowSoftInputMode=“adjustPan” hiding actionbar and adjust resize shrinking layout

在聊天應用程序中,我有一個以圖像為背景的活動。當我輸入一條消息發布電話鍵盤時,當我在清單文件中使用windowSoftInputMode =“adjustResize”時,我的布局會縮小。當我使用時windowSoftInputMode =“adjustPan”手機鍵盤隱藏操作欄。這兩個問題在當今市場上的許多應用程序中得到了很好的解決,例如whatsapp chat.Please幫助我在我的app中解決這個問題.Below是我的聊天活動的布局。

<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>

您可以創建一個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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM