2017-02-16 4 views
0

Создал вид деятельности с формой. Поскольку форма довольно длинная, поэтому я использовал scrollview. Проблема в том, что scrollview не изменяется, когда клавиатура вставлена. Клавиатура перекрывает последнюю часть прокрутки.ScrollView не настраивался при открытии клавиатуры

я использовал мин SDk 16 мишени из 25.

я боролся в этой проблеме может кто-нибудь может помочь мне в этом, заранее спасибо.

Вот проблема в этом образе enter image description here

Я хочу быть, как это (отредактированный PIC) enter image description here

я пытался изменить манифест, используя этот код:

android:windowSoftInputMode="stateAlwaysHidden|adjustResize|adjustPan" 

и этот код в моей деятельности

context.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); 

Вот полный XML

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView 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:id="@+id/activity_create_new_user" 
    style="@android:style/Widget.DeviceDefault.Light.ScrollView" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/colorPrimary" 
    android:paddingTop="22dp" 
    android:scrollbarSize="20dp" 
    tools:context="com.jlmaychinny.app.cashbilis.Ui_Activities.CreateNewUserActivity"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:paddingBottom="@dimen/nav_header_vertical_spacing" 
     android:paddingLeft="@dimen/nav_header_vertical_spacing" 
     android:paddingRight="@dimen/nav_header_vertical_spacing" 
     android:paddingTop="10dp"> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:padding="5dp" 
      android:text="Create your account by providing the following." 
      android:textAlignment="center" 
      android:textColor="@android:color/white" 
      android:textSize="16sp" 
      tools:ignore="HardcodedText" /> 

     <com.jlmaychinny.app.cashbilis.CircleImageView.CircleImageView 
      android:id="@+id/createnewuser_profile_image" 
      android:layout_width="150dp" 
      android:layout_height="150dp" 
      android:layout_gravity="center" 
      android:src="@drawable/person_icon" 
      app:civ_border_color="@color/colorPrimaryDark" 
      app:civ_border_width="5dp" /> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="Name:" 
      android:textColor="@android:color/white" 
      tools:ignore="HardcodedText" /> 

     <EditText 
      android:id="@+id/createnewuser_name" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="10dp" 
      android:background="@drawable/edittext_design" 
      android:hint="Juan Dela Cruz" 
      android:inputType="textPersonName" 
      android:textAlignment="center" 
      android:textColor="@android:color/black" 
      android:textColorHint="@android:color/darker_gray" 
      android:textSize="18sp" 
      tools:ignore="HardcodedText" /> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="State:" 
      android:textColor="@android:color/white" 
      tools:ignore="HardcodedText" /> 

     <EditText 
      android:id="@+id/createnewuser_address_state" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="10dp" 
      android:background="@drawable/edittext_design" 
      android:hint="Davao Del Sur" 
      android:inputType="textPostalAddress" 
      android:textAlignment="center" 
      android:textColor="@android:color/black" 
      android:textColorHint="@android:color/darker_gray" 
      android:textSize="18sp" 
      tools:ignore="HardcodedText" /> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="City:" 
      android:textColor="@android:color/white" 
      tools:ignore="HardcodedText" /> 

     <EditText 
      android:id="@+id/createnewuser_address_city" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="10dp" 
      android:background="@drawable/edittext_design" 
      android:hint="Davao City" 
      android:inputType="textPostalAddress" 
      android:textAlignment="center" 
      android:textColor="@android:color/black" 
      android:textColorHint="@android:color/darker_gray" 
      android:textSize="18sp" 
      tools:ignore="HardcodedText" /> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="Home Address:" 
      android:textColor="@android:color/white" 
      tools:ignore="HardcodedText" /> 

     <EditText 
      android:id="@+id/createnewuser_address_home" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="10dp" 
      android:background="@drawable/edittext_design" 
      android:hint="Blk.16 Pag-asa st.,Brgy. Forever" 
      android:inputType="textPostalAddress" 
      android:textAlignment="center" 
      android:textColor="@android:color/black" 
      android:textColorHint="@android:color/darker_gray" 
      android:textSize="18sp" 
      tools:ignore="HardcodedText" /> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="Email:" 
      android:textColor="@android:color/white" 
      tools:ignore="HardcodedText" /> 

     <EditText 
      android:id="@+id/createnewuser_email" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="10dp" 
      android:background="@drawable/edittext_design" 
      android:hint="[email protected]" 
      android:inputType="textEmailAddress" 
      android:textAlignment="center" 
      android:textColor="@android:color/black" 
      android:textColorHint="@android:color/darker_gray" 
      android:textSize="18sp" 
      tools:ignore="HardcodedText" /> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      android:weightSum="10"> 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_vertical" 
       android:layout_weight="8" 
       android:text="Password:" 
       android:textColor="@android:color/white" 
       tools:ignore="HardcodedText" /> 

      <ImageButton 
       android:id="@+id/createnewuser_show_password" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_weight="2" 
       android:background="@android:color/transparent" 
       android:padding="5dp" 
       android:src="@drawable/ic_visibility" 
       tools:ignore="ContentDescription" /> 

     </LinearLayout> 

     <EditText 
      android:id="@+id/createnewuser_password" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="10dp" 
      android:background="@drawable/edittext_design" 
      android:hint="************" 
      android:inputType="textPassword" 
      android:textAlignment="center" 
      android:textColor="@android:color/black" 
      android:textColorHint="@android:color/darker_gray" 
      android:textSize="18sp" 
      tools:ignore="HardcodedText" /> 

     <EditText 
      android:id="@+id/createnewuser_password_confirm" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="10dp" 
      android:background="@drawable/edittext_design" 
      android:hint="Confirm your password" 
      android:inputType="textPassword" 
      android:textAlignment="center" 
      android:textColor="@android:color/black" 
      android:textColorHint="@android:color/darker_gray" 
      android:textSize="18sp" 
      tools:ignore="HardcodedText" /> 

     <Button 
      android:id="@+id/createnewuser_btn" 
      android:layout_width="match_parent" 
      android:layout_height="60dp" 
      android:background="@drawable/button" 
      android:text="CREATE USER" 
      android:textColor="@android:color/white" 
      tools:ignore="HardcodedText" /> 

    </LinearLayout> 
</ScrollView> 
+0

Try 'андроида: fillViewport = "истинный"' в Scrollview. –

+0

такой же результат. это не исправить проблему – gunZ333

+0

вы можете опубликовать полный код xml, чтобы я мог проверить проблему. – dipali

ответ

0

добавить андроид: windowSoftInputMode = "adjustPan" в mainfiest файла внутри вашей деятельности и использовать в экскурсионном XML в использовании EditText андроид: SingleLine = "истинного"

+0

спасибо! но все же кнопка скрывается в задней части клавиатуры клавиатуры – gunZ333

+0

вы можете использовать действие для редактирования текста, используя андроид: imeOptions = "actionDone" –

+0

keybord будет скрываться после нажатия кнопки в androoid –

0

Я думаю, что это связано с тем, что вы поддерживаете «adjustResize | adjustPan».

Просто удалите adjustPan Ваш Androidmainfest.xml (например: андроид: windowSoftInputMode = "stateAlwaysHidden | adjustResize"). , а также удалить context.getWindow() setSoftInputMode (WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); из вашего java-файла.

Я думаю, это поможет вам.

0

Вы должны попробовать использовать addOnLayoutChangeListener на вашем Scrollview следующим образом:

scrollView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { 
      @Override 
      public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { 
       if (bottom < oldBottom) { 
        scrollView.postDelayed(new Runnable() { 
         @Override 
         public void run() { 
          scrollView.fullScroll(ScrollView.FOCUS_DOWN); 
         } 
        }, 100); 
       } 
      } 
     }); 
Смежные вопросы