2017-04-10 40 views
0

我正在開發一個應用程序,我發現一個問題,鍵盤隱藏EditText字段。在研究中,我通過在清單文件中添加這行代碼找到了解決方案。鍵盤覆蓋編輯文本的一半Android

android:windowSoftInputMode="adjustPan" 

,但現在我的EditText看起來像this

的表情圖標,編輯文本和發送的TextView是一個線性佈局。我如何顯示鍵盤上方的整個線性佈局?

+0

希望這[答案](http://stackoverflow.com/a/28012530/2347794)幫助你.... – Safa

回答

0

我有完全一樣的問題adjustPan所以我用這個代替..

android:windowSoftInputMode="adjustResize" 

我希望你的根佈局RelativeLayout

UPDATE

嘗試設置這樣的。

chat_ui.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:id="@+id/chat_layout" 
    android:background="@color/white"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/applayout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="@color/white" 
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light"> 

      <TextView 
       android:id="@+id/txtTitle" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginRight="40dp" 
       android:gravity="center_horizontal" 
       android:text="Francis" 
       android:textColor="@color/page_background" 
       android:textSize="10pt" /> 

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

    </android.support.design.widget.AppBarLayout> 

    <ListView 
     android:layout_below="@id/applayout" 
     android:id="@+id/chat_list_view" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_above="@+id/bottomlayout" 
     android:layout_marginBottom="4dp" 
     android:clipToPadding="false" 
     android:divider="@drawable/chat_divider" 
     android:paddingBottom="4dp" 
     android:paddingTop="8dp" 
     android:scrollbarStyle="outsideOverlay" 
     android:stackFromBottom="false" 
     android:transcriptMode="normal" /> 

    <LinearLayout 
     android:id="@+id/bottomlayout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" 
     android:layout_marginLeft="8dp" 
     android:layout_marginRight="8dp" 
     android:orientation="horizontal"> 

     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_gravity="bottom" 
      android:layout_weight="1" 
      android:background="@drawable/input" 
      android:minHeight="50dp" 
      android:orientation="horizontal" 
      android:paddingBottom="15dp" 
      android:paddingLeft="12dp" 
      android:paddingRight="20dp"> 

      <!-- <ImageView 
        android:id="@+id/emojiButton" 
        android:layout_width="24dp" 
        android:layout_height="24dp" 
        android:layout_gravity="bottom" 
        android:src="@drawable/input_emoji" />--> 

      <EditText 
       android:id="@+id/chat_edit_text1" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_gravity="bottom" 
       android:layout_marginLeft="12dp" 
       android:background="@null" 
       android:hint="@string/type_message" 
       android:inputType="textMultiLine" 
       android:singleLine="false" 
       android:textColorHint="#c4c0bd" 
       android:textSize="18sp" /> 

     </LinearLayout> 

     <ImageButton 
      android:id="@+id/enter_chat1" 
      android:layout_width="50dp" 
      android:layout_height="50dp" 
      android:layout_gravity="bottom" 
      android:background="@drawable/input_circle_normal" 
      app:srcCompat="@drawable/ic_send" /> 

    </LinearLayout> 

</RelativeLayout> 

和清單

<activity 
    android:name=".activities.ChatActivity" 
    android:windowSoftInputMode="stateHidden|adjustResize" 
    android:screenOrientation="portrait" 
    android:theme="@style/MyMaterialTheme2" /> 
+0

試過了,沒有工作:(它完全覆蓋了我的editText –

+0

檢查我的更新..其我的聊天應用程序的工作代碼,其工作良好在我的moto-g4加上牛軋糖版本 –

+0

沒有爲我工作:(感謝更新的答案,雖然 –

0

設置機器人:softInputMode屬性在艙單adjustResize,並把佈局(未列出的項目佈局)滾動型內。

+0

對不起,我不明白最後一部分「把佈局(不列表項目佈局)「 –

+0

我的意思是如果你已經使用了listview,那麼不要把scrollview放到listview的佈局中,你可能會忽略它,請把layout的scrollview放在那個edittext框裏,發送按鈕,所有的都來。 –