2016-12-13 4 views
0

Android, когда я нажимаю на текст редактирования в нижней части моего макета полный экран перемещается в полноэкранном активностьКлавиатура Android вверх двигаться вверх весь мой экран

When key board is hidden

когда клавиатура вверх макет на вершине используется для перемещения по экрану, но я хочу, чтобы макет показано

When keyboard is up the layout at top used to move

Это мой макет код

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/layout_chat_container" 
    style="@style/MatchParent" 
    tools:ignore="RtlHardcoded"> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/ll_action" 
     android:orientation="vertical"> 
     <RelativeLayout 
      android:id="@+id/navbar" 
      android:layout_width="fill_parent" 
      android:layout_height="76dp" 
      android:visibility="visible" 
      > 
      <LinearLayout 
       android:id="@+id/ll_view" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal" 
       android:background="@drawable/statusbar"></LinearLayout> 
      <View 
       android:id="@+id/line" 
       android:layout_width="match_parent" 
       android:layout_height="2dp" 
       android:background="#ffff01" 
       android:layout_below="@+id/ll_view"/> 

      <LinearLayout 
       android:id="@+id/ll_back_button" 
       android:layout_width="50dp" 
       android:layout_height="50dp" 
       android:visibility="visible" 
       android:layout_marginTop="25dp" 
       android:orientation="vertical"> 

      </LinearLayout> 
      <RelativeLayout 
       android:layout_width="50dp" 
       android:layout_alignParentRight="true" 
       android:layout_marginRight="5dp" 
       android:layout_below="@+id/line" 
       android:onClick="onStartNewChatClick" 
       android:layout_height="match_parent"> 
       <ImageView 
        android:id="@+id/fab_dialogs_new_chat" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:background="@drawable/qb_info" 
        android:visibility="visible" 
        android:layout_gravity="center" 
        android:layout_centerInParent="true" 


        /> 
      </RelativeLayout> 
      <RelativeLayout 
       android:layout_width="50dp" 
       android:layout_alignParentLeft="true" 
       android:layout_marginLeft="5dp" 
       android:layout_below="@+id/line" 
       android:onClick="onStartNewChatBack" 
       android:layout_height="match_parent"> 
       <ImageView 
        android:id="@+id/img_back" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:background="@drawable/qb_back" 
        android:visibility="visible" 
        android:layout_gravity="center" 
        android:layout_centerInParent="true" 


        /> 
      </RelativeLayout> 
     <RelativeLayout 
      android:layout_width="wrap_content" 
      android:layout_centerInParent="true" 
      android:layout_below="@+id/line" 
      android:layout_height="match_parent"> 

      <TextView 
       android:id="@+id/txtv_myuserloginname" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerVertical="true" 
       android:text="USER" 
       android:layout_marginTop="10dp" 
       android:layout_centerHorizontal="true" 
       android:textColor="#222222" 
       android:gravity="center" 
       android:textSize="15dp" 
       /> 
     </RelativeLayout> 
     </RelativeLayout> 
     <View 
      android:id="@+id/view" 
      android:layout_below="@+id/navbar" 
      android:layout_width="match_parent" 
      android:layout_height="2dp" 
      android:background="#ffff01"/> 
    </LinearLayout> 

    <se.emilsjolander.stickylistheaders.StickyListHeadersListView 
     android:id="@+id/list_chat_messages" 
     style="@style/ListViewWithoutDividerStyle" 
     android:layout_above="@+id/layout_attachment_preview_container" 
     android:layout_below="@+id/ll_action" 
     android:listSelector="@android:color/transparent" 
     android:stackFromBottom="true" /> 

    <ProgressBar 
     android:id="@+id/progress_chat" 
     style="@style/CenterProgressBarStyle" /> 

    <LinearLayout 
     android:id="@+id/layout_attachment_preview_container" 
     style="@style/MatchWidth" 
     android:layout_height="96dp" 
     android:layout_above="@+id/layout_chat_send_container" 
     android:background="?attr/colorPrimary" 
     android:orientation="vertical" 
     android:visibility="gone"> 

     <View 
      android:id="@+id/divider_chat_attachments" 
      style="@style/HorizontalDividerStyle" /> 

     <com.quickblox.sample.chat.ui.widget.AttachmentPreviewAdapterView 
      android:id="@+id/adapter_view_attachment_preview" 
      style="@style/MatchWidth" /> 
    </LinearLayout> 

    <View 
     android:id="@+id/divider_chat" 
     style="@style/HorizontalDividerStyle" 
     android:layout_above="@+id/layout_chat_send_container" /> 

    <LinearLayout 
     android:id="@+id/layout_chat_send_container" 
     style="@style/MatchWidth" 
     android:layout_alignParentBottom="true" 
     android:background="?attr/colorPrimary" 
     android:orientation="horizontal"> 

     <ImageButton 
      android:id="@+id/button_chat_attachment" 
      style="@style/BorderlessImageButtonStyle" 
      android:layout_gravity="center_vertical" 
      android:onClick="onAttachmentsClick" 
      android:src="@drawable/ic_action_attachment" /> 

     <EditText 
      android:id="@+id/edit_chat_message" 
      style="@style/WeightWidth" 
      android:layout_height="wrap_content" 
      android:hint="@string/chat_edit_text_hint" 
      android:inputType="textShortMessage" 
      android:maxLength="1024" /> 

     <ImageButton 
      android:id="@+id/button_chat_send" 
      style="@style/BorderlessImageButtonStyle" 
      android:layout_gravity="center_vertical" 
      android:onClick="onSendChatClick" 
      android:src="@drawable/ic_send" 
      android:text="@string/chat_send" /> 
    </LinearLayout> 
</RelativeLayout> 

Java код

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
      WindowManager.LayoutParams.FLAG_FULLSCREEN); 
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); 

Manifest

<activity 
     android:name=".ui.activity.ChatMenu" 
     android:screenOrientation="portrait" 
     android:theme="@style/ChatActivityTheme" 
     android:windowSoftInputMode="stateHidden|adjustResize" /> 

Стиль

<style name="ChatActivityTheme" parent="AppTheme"> 
     <item name="android:windowBackground">@color/background_chat_color</item> 

    </style> 

как избежать верхней макет не двигаться с клавиатуры, но редактировать текст должен двигаться клавиатура в FullScreen activi ty

+0

прочитать http://android-developers.blogspot.in/2009/04/updating-applications- for-on-screen.html –

ответ

0

Вы пробовали это?

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

doc here

тогда вся ваша раскладка не будет изменять размер. если вы хотите переместить только ваш EditText, вам нужно измерить размер клавиатуры/вашего доступного экрана (потому что она будет меньше при наличии клавиатуры)

нет «стандартного» способа предотвращения изменения размера и приклеивания только части View до верхняя часть клавиатуры (насколько я знаю)

+0

Да, вид редактирования не двигался вверх –

+0

может у, пожалуйста, скажите мне, как это сделать –

+0

проверить [этот вопрос и ответ] (http://stackoverflow.com/questions/16788959/is-there-any-way-in-android-to-get-the-height-of-virtual-keyboard-of- устройство), и перемещайте свой 'EditText' каждый раз, когда размер изменен. – snachmsm

0

попытаться использовать это на AndroidManifest.xml

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

он использует это в настоящее время, он не хочет изменять размер всего макета, только придерживаться куска макета поверх клавиатуры – snachmsm

Смежные вопросы