3

我有一個問題,點擊我的佈局底部的EditText,顯示一個軟鍵盤。問題是,當我點擊EditText和軟鍵盤顯示,我可以通過我的ListView滾動,但我已經宣佈之前的列表視圖中的佈局,這是ActionBarRelativeLayout,都是隱藏的。在我的AndroidManifest中,我宣稱:android:windowSoftInputMode="stateAlwaysHidden|adjustPan"。我以爲這是因爲我沒有添加ScrollView作爲我的佈局的父母,但是當我這樣做時,沒有任何改變。這是我的嘗試:軟鍵盤隱藏佈局的一部分?

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:fresco="http://schemas.android.com/apk/res-auto" 
    android:orientation="vertical" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fillViewport="true"> 
<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:id="@+id/comments_layout"> 

    <android.support.design.widget.AppBarLayout android:layout_height="wrap_content" 
     android:layout_width="match_parent" android:theme="@style/AppTheme.AppBarOverlay" 
     android:id="@+id/comments_appbar"> 

    <android.support.v7.widget.Toolbar android:id="@+id/comments_toolbar" 
     android:layout_width="match_parent" android:layout_height="wrap_content" 
     android:background="?attr/colorPrimary" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
     app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /> 

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

    <RelativeLayout 
     android:layout_below="@id/comments_appbar" 
     android:id="@+id/view_post" 
     android:layout_width="match_parent" 
     android:paddingRight="5dp" 
     android:paddingLeft="5dp" 
     android:orientation="horizontal" 
     android:layout_height="175dp" 
     android:background="#e6e6e6"> 

     <com.facebook.drawee.view.SimpleDraweeView 
      android:layout_marginTop="15dp" 
      android:id="@+id/poster_picture" 
      android:layout_width="75dp" 
      android:layout_height="75dp" 
      android:layout_marginLeft="10dp" 
      fresco:placeholderImage="@mipmap/blank_prof_pic" 
      fresco:roundedCornerRadius="5dp" 
      /> 

     <TextView 
      android:layout_marginLeft="5dp" 
      android:layout_marginTop="15dp" 
      android:layout_toRightOf="@id/poster_picture" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textSize="15sp" 
      android:textStyle="bold" 
      android:id="@+id/poster_name"/> 

     <TextView 
      android:layout_alignParentRight="true" 
      android:layout_marginTop="15dp" 
      android:layout_toRightOf="@id/poster_name" 
      android:layout_marginLeft="5dp" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textSize="15sp" 
      android:id="@+id/post_date"/> 

     <TextView 
      android:layout_marginLeft="5dp" 
      android:layout_toRightOf="@id/poster_picture" 
      android:layout_below="@id/poster_name" 
      android:textSize="20sp" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:id="@+id/view_status" /> 

    </RelativeLayout> 

      <ListView 
       android:id="@+id/lv_comments_feed" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_above="@+id/send_message" 
       android:layout_below="@+id/view_post"> 
      </ListView> 

     <LinearLayout 
      android:id="@+id/send_message" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:padding="5dp" 
      android:layout_alignParentBottom="true" 
      android:orientation="horizontal" > 

      <EditText 
       android:id="@+id/write_comment" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_vertical|center_horizontal" 
       android:layout_weight="5" 
       android:gravity="top|left" 
       android:hint="Comment back!" 
       android:inputType="textMultiLine" 
       android:background="@color/white" 
       android:scrollHorizontally="false" /> 

      <Button 
       android:id="@+id/send_comment" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_vertical|center_horizontal" 
       android:gravity="center" 
       android:text="send" 
       android:textAppearance="?android:attr/textAppearanceMedium" /> 
     </LinearLayout> 

</RelativeLayout> 
    </ScrollView> 

在一開始RelativeLayout,與ActionBar都隱藏着一起,但是當我的軟鍵盤彈出我還可以通過我的ListView滾動沒有問題,我點擊我的EditText。有想法該怎麼解決這個嗎?謝謝!

回答

1

而不是

機器人:windowSoftInputMode = 「stateAlwaysHidden | adjustPan」

寫下

機器人:windowSoftInputMode = 「adjustPan | adjustResize」

這將有助於

+0

這並沒有幫助,因爲我'EditText'消失,我打字的區域似乎被隱藏鍵盤(它與'EditText'重疊)。此外,如果任何事情我想一下'EditText'時只需推升的佈局,因爲這將有助於我能夠看到鍵盤的'EditText',如果我向上或向下滾動,我可以看到的佈局。 – user1871869

0

我sol通過使用

android:isScrollContainer="false" 

,滾動型和清單文件,粘彈性阻尼器這個問題加入

android:windowSoftInputMode="adjustResize"