2017-01-01 56 views
0

softKeyBoard推高我的佈局。我嘗試了鍵盤的所有建議,但它沒有幫助,佈局被推高,我嘗試在代碼中添加以下行:getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); 但這不起作用。請我需要幫助。softKeyBoard推高我的佈局

這是我的片段xml。

<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@drawable/chat_bg" 
android:isScrollContainer="false"> 


<LinearLayout 
    android:id="@+id/chatRetryArea" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="100dp" 
    android:gravity="center" 
    android:orientation="horizontal" 
    android:visibility="visible"> 

    <com.android.shanti.customViews.CustomTextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:text="@string/groupChatIsNotAvailable" 
     android:textColor="@color/gray_dark" /> 

    <com.android.shanti.customViews.CustomTextView 
     android:id="@+id/chatRetryLoad" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:paddingEnd="5dp" 
     android:paddingStart="10dp" 
     android:text="@string/groupChatIsNotAvailableRetry" 
     android:textColor="@color/purple_home" /> 

</LinearLayout> 


<RelativeLayout 
    android:id="@+id/chatLoadingPanel" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_centerInParent="true" 
    android:gravity="center"> 

    <ProgressBar 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:indeterminate="true" /> 

</RelativeLayout> 


<ListView 
    android:id="@+id/chatHistoryList" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_above="@+id/chatTools" 
    android:background="@color/green" 
    android:divider="@android:color/transparent" 
    android:dividerHeight="20dp" 
    android:padding="10dp" /> 

<RelativeLayout 
    android:id="@+id/chatTools" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:background="@color/white" 
    android:orientation="horizontal" 
    android:padding="20dp"> 

    <com.android.shanti.customViews.CustomEditText 
     android:id="@+id/chatMessageText" 
     android:layout_width="255dp" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     android:background="@color/transparent" 
     android:enabled="false" 
     android:maxLines="5" 
     android:paddingEnd="13dp" 
     android:paddingStart="13dp" /> 
</RelativeLayout> 

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="60dp" 
    android:layout_alignParentBottom="true" 
    android:orientation="horizontal" 
    android:padding="20dp"> 

    <ImageView 
     android:id="@+id/chatSendClick" 
     android:layout_width="30dp" 
     android:layout_height="30dp" 
     android:layout_alignParentEnd="true" 
     android:layout_centerVertical="true" 

     android:background="@drawable/send_right" /> 

    <ImageView 
     android:id="@+id/chatMessageBackground" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     android:layout_marginStart="90dp" 
     android:background="@drawable/chat_message_text" /> 

    <ImageView 
     android:id="@+id/chatAttachmentBtn" 
     android:layout_width="30dp" 
     android:layout_height="30dp" 
     android:layout_alignParentStart="true" 
     android:layout_centerVertical="true" 
     android:background="@drawable/chat_add_attachment" 
     android:clickable="true" 
     android:enabled="false" /> 

</RelativeLayout> 


</RelativeLayout> 

的AndroidManifest.xml:

<activity 
android:name=".main.MainActivity" 
android:configChanges="orientation|keyboardHidden|screenSize" 
android:label="@string/title_activity_main" 
android:launchMode="singleTop" 
android:windowSoftInputMode="adjustPan|adjustNothing" 
android:screenOrientation="portrait"/> 

<activity 
android:name=".login.signin.SignUpActivity" 
android:label="@string/title_activity_sign_up" 
android:windowSoftInputMode="adjustPan|adjustNothing" 
android:screenOrientation="portrait"/> 
+0

嘗試僅僅機器人: windowSoftInputMode =「adjustNothing」 –

+0

我試過了。它仍然不起作用 –

+0

@ h.g。你想在鍵盤出現時推送佈局,或保持佈局原樣,問題有點不清楚? –

回答

1

如果你想防止軟鍵盤從推你的觀點了 做這樣在你的相關活動標籤

<activity 
    ... 
    android:windowSoftInputMode="adjustPan"> 
</activity> 
+0

看!它存在 –

+0

你試過只用adjustPan出來adjustNothing –

+0

是的,我只試過adjustPan –