1. 程式人生 > 程式設計 >Android仿微信QQ聊天頂起輸入法不頂起標題欄的問題

Android仿微信QQ聊天頂起輸入法不頂起標題欄的問題

在這記錄一下輸入法彈出的一系列問題,有的輸入法彈出就把整個佈局彈上去,有的輸入法彈出佈局不會有變化,有的輸入法彈出遮蓋輸入框等等問題,網上也有很多說加著加那的,但是看一下都不是很完整,解決不了所有問題,我在這歸納一下大家拿去用吧!

*****先看看做好的效果圖*****

一:AndroidManifest.xml裡面對應的activity設定

android:windowSoftInputMode="adjustResize"

二:在activity的xml根佈局設定

android:fitsSystemWindows="true"

三:為了listview聊天列表的效果,在listview設定

android:transcriptMode="normal"

四:最後貼上一下每個用到的地方程式碼

1:AndroidManifest.xml

<!--聊天室-->
  <activity
   android:name=".activity.ChatRoom"
   android:screenOrientation="portrait"
   android:windowSoftInputMode="adjustResize"/>

2:activity的xml根佈局和listview

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:background="@color/xmlback"
 android:fitsSystemWindows="true">
 <include
  android:id="@+id/include"
  layout="@layout/titlelayout" />
 <ListView
  android:id="@+id/listview"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:layout_above="@+id/botton"
  android:layout_below="@+id/include"
  android:background="@color/xmlback"
  android:divider="@null"
  android:scrollbars="none"
  android:transcriptMode="normal"></ListView>
 <RelativeLayout
  android:id="@+id/botton"
  android:layout_width="match_parent"
  android:layout_height="70dp"
  android:layout_alignParentBottom="true"
  android:background="@drawable/hlistvbackwl1">
  <RelativeLayout
   android:layout_width="match_parent"
   android:layout_height="50dp"
   android:layout_centerVertical="true"
   android:layout_marginLeft="10dp"
   android:layout_toLeftOf="@+id/textsend"
   android:background="@drawable/ltback">
   <EditText
    android:id="@+id/edittext"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginLeft="10dp"
    android:background="@null"
    android:hint="輸入聊天內容"
    android:textSize="14dp" />
  </RelativeLayout>
  <TextView
   android:id="@+id/textsend"
   android:layout_width="50dp"
   android:layout_height="50dp"
   android:layout_alignParentRight="true"
   android:layout_centerVertical="true"
   android:gravity="center"
   android:text="傳送"
   android:textColor="@color/zhucolor"
   android:textSize="14dp" />
 </RelativeLayout>
</RelativeLayout>

總結

以上所述是小編給大家介紹的Android仿微信QQ聊天頂起輸入法不頂起標題欄的問題,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回覆大家的。在此也非常感謝大家對我們網站的支援!
如果你覺得本文對你有幫助,歡迎轉載,煩請註明出處,謝謝!