2015-05-19 134 views
0

我有一個EditText和一個LinearLayout中,但在輸入上的EditText膠囊包裹的按鈕,Android手機上的鍵盤,儘管指定Android鍵盤隱藏LinerLayout

this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); 

 <activity 
     android:name=".postNavigator" 
     android:label="@string/title_activity_post_navigator" 

     android:windowSoftInputMode="adjustPan|adjustResize"> 

    </activity> 
的隱藏佈局

Keyboard hides the EditText

我的XML代碼

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="com.dailyspring.rejo.cpray.postNavigator"> 

<!--<ImageView--> 
<!--android:layout_width="fill_parent"--> 
<!--android:layout_height="fill_parent"--> 
<!--android:scaleType="centerCrop"--> 
<!--android:src="@drawable/back_blur" />--> 

<LinearLayout android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:weightSum="2" 
    android:layout_height="match_parent"> 



    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginLeft="15sp" 
     android:layout_marginRight="15sp" 
     android:layout_marginTop="15sp" 
     android:layout_weight="1" 
     android:orientation="vertical" 
     android:weightSum="1"> 

     <com.github.leonardoxh.customfont.FontText 
      android:id="@+id/title" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:layout_marginBottom="10sp" 
      android:text="Post Title" 
      android:textAlignment="center" 

      android:textSize="25dp" 
      app:font="Roboto-Thin" /> 
     <com.github.leonardoxh.customfont.FontText 
      android:id="@+id/authorName" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:layout_marginBottom="10sp" 
      android:text="Author" 
      android:textAlignment="center" 
      android:textSize="15dp" 
      app:font="Roboto-Thin" /> 

     <ScrollView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      > 

      <TextView 
       android:id="@+id/txtDesc" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 

       android:text="DescriptionDescription Description Description DescriptionDescription Description Description Description Description Descriptionescription sDescripti Description Description Description Description Description Description Descriptionescription sDescripti Description Description Description Description Description Description Description" /> 
     </ScrollView> 


    </LinearLayout> 
    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical" 
     android:layout_weight="1"> 
     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="0.5"> 
      <RelativeLayout 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent"> 
       <ProgressBar 
        android:layout_width="fill_parent" 
        android:layout_gravity="top" 
        android:layout_height="55dp" 
        android:id="@+id/loadingProgressBar"/> 
       <LinearLayout 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_weight="1.3" 
        android:orientation="vertical" 
        android:layout_marginLeft="15sp" 
        android:layout_marginRight="15sp" 
        android:layout_marginTop="15sp"> 

        <com.github.leonardoxh.customfont.FontText 
         android:id="@+id/commentTitle" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_gravity="left" 
         android:layout_marginBottom="10sp" 
         android:text="Comments" 
         android:textAlignment="center" 
         android:textSize="15dp" 
         app:font="Roboto-Thin" /> 


        <ListView 
         android:id="@+id/listcomments" 
         android:layout_width="fill_parent" 
         android:layout_height="fill_parent" 
         android:divider="@null" 
         android:dividerHeight="0dp" 
         android:paddingBottom="10dp" 
         android:fadeScrollbars="false" 
         android:listSelector="@drawable/list_selector" 
         android:background="@drawable/rounded_corner_nobg" 
         android:transcriptMode="alwaysScroll" 
         android:stackFromBottom="true"/> 
       </LinearLayout> 


      </RelativeLayout> 
     </LinearLayout> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_weight="1" 
       android:layout_marginBottom="15sp" 
       android:layout_marginLeft="15sp" 
       android:layout_marginRight="15sp" 
       android:layout_marginTop="15sp" 
       android:orientation="horizontal"> 

       <EditText 
        android:id="@+id/commentText" 

        android:layout_width="fill_parent" 
        android:layout_height="50dp" 
        android:paddingLeft="10dp" 
        android:background="@drawable/rounded_corner" 
        android:imeOptions="flagNoFullscreen" 
        android:hint=" add comment" 
        android:layout_weight="0.5"/> 
       <at.markushi.ui.CircleButton 

        android:layout_width="53dp" 
        android:layout_height="53dp" 
        android:id="@+id/pickImage" 
        android:src="@drawable/ic_send_white_48dp" 
        app:cb_color="#99CC00" 
        app:cb_pressedRingWidth="5dip" /> 

      </LinearLayout> 
    </LinearLayout> 
</LinearLayout> 

我試過調整android:layout_weight和調整邊距和填充,但沒有什麼幫助。我該如何解決這個問題?

+0

你讀它 - http://stackoverflow.com/questions/17410499/difference-between-adjustresize-and-adjustpan-in-android? – Divers

+0

是的。指定任何一個都沒有幫助。仍然隱藏佈局 –

回答

0

android:windowSoftInputMode不能是東西或東西,你應該在這裏只設置一個值。在你的情況下,我認爲你需要adjustPan。

順便說一句,你爲什麼使用所有的重量?它在你的佈局中有些混亂。您的UI可以用簡單的垂直方向LinearLayout來實現。還有ScrollView裏面的TextView?使用maxLines參數。

+0

我試過給一個,但不工作 –

+0

@RejoChandran Complitly重新佈局你的用戶界面,因爲我建議,一切都會好的。 – Divers

+0

我猜佈局需要再次工作;無論如何,android:windowSoftInputMode =「adjustResize」應該將所有元素從屏幕上移開,不管對齊如何... –

-1

使用windowSoftInputMode,像這樣:

android:windowSoftInputMode="adjustPan"