在聊天应用程序中,我有一个以图像为背景的活动。现在当我输入一条消息来发布手机键盘时,当我使用windowSoftInputMode =" adjustResize"时,我的布局会缩小。在清单文件中。当我使用windowSoftInputMode =" adjustPan"手机键盘隐藏动作栏。这两个问题在当今市场上的许多应用中得到了很好的解决,例如whatsapp chat.Please帮我在我的应用中解决这个问题.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>
答案 0 :(得分: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>