2015-05-19 120 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"