2013-01-13 14 views
6

Wiem, że istnieje wiele pytań na temat SO związanych z EditText, pokazujących miękką klawiaturę wejściową i co powinieneś mieć w manifeście (adjustPan lub adjustResize).Miękka klawiatura nie uruchamia spustu w ScrollView

Przeczytałem wiele pytań i odpowiedzi tutaj, ale nie byłem w stanie rozwiązać mojego problemu.

Jest to całkiem proste: Mam login i wszystkie treści mieszczą się na jednym ekranie, gdy klawiatura NIE jest wyświetlana. U dołu tej czynności logowania mam przycisk, który powinien zawsze znajdować się na dole. Podczas ustawiania ostrości na jednym EditText, klawiatura pokazuje i ukrywa pewne rzeczy. Gdy klawiatura jest podniesiona, chciałbym móc przewinąć w dół, ale nie mogę.

  • mam ustawić aktywność do "adjustPan" w oczywisty

Oto dwa obrazy, bez iz klawiatury:

enter image description here enter image description here

Teraz, gdy klawiatura jest podniesiona, chciałbym przewinąć w dół, aby zobaczyć przyciski (żółty i na dole). Nie mogę tego zrobić.

Gdybym zamiast ustawić w manifeście, do „adjustRezise”, mam inny niepożądany efekt jak widać tutaj:

enter image description here

przycisk u dołu ma „na szczycie” inne rzeczy, ale nie mogę przewijać (tak, że można wyświetlić przycisk "logga in").

Pierwsze pytanie brzmi: dlaczego nie funkcjonuje przewijanie za pomocą "adjustPan" i kiedy klawiatura ukrywa coś? To jest rozsądna rzecz, którą powiedziałbym.

Tu jest mój XML:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/linearLayout6" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@drawable/taxibg3" 
    android:orientation="vertical" > 

    <ScrollView 
     android:id="@+id/ScrollView" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_below="@id/login_logoBarInclude" 
     android:fillViewport="true" 
     android:orientation="vertical" > 

     <RelativeLayout 
      android:id="@+id/login_form" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" > 

      <LinearLayout 
       android:id="@+id/iv1" 
       android:layout_width="240dp" 
       android:layout_height="280dp" 
       android:layout_centerHorizontal="true" 
       android:layout_marginTop="5dp" 
       android:background="@drawable/login_square_adapted" 
       android:orientation="vertical" 
       android:paddingTop="15dp" > 

       <TextView 
        android:id="@+id/textView1" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:gravity="center_horizontal" 
        android:text="@string/vehicleLogin" 
        android:textAppearance="?android:attr/textAppearanceMedium" 
        android:textColor="#ffffff" /> 

       <FrameLayout 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="3dp" 
        android:layout_marginRight="3dp" 
        android:layout_marginTop="10dp" > 

        <include layout="@layout/menu_divider_horizontal" > 
        </include> 
       </FrameLayout> 

       <RelativeLayout 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="30dp" 
        android:layout_marginRight="30dp" 
        android:layout_marginTop="35dp" 
        android:gravity="center_horizontal" 
        android:orientation="vertical" > 

        <EditText 
         android:id="@+id/login_carNumber" 
         style="@style/EditTextDark" 
         android:layout_width="fill_parent" 
         android:layout_height="wrap_content" 
         android:layout_toRightOf="@+id/login_car_icon" 
         android:hint="@string/prompt_carNumber" 
         android:inputType="phone" 
         android:textAppearance="?android:attr/textAppearanceMedium" 
         android:textCursorDrawable="@null" > 

         <requestFocus /> 
        </EditText> 

        <ImageView 
         android:id="@+id/login_car_icon" 
         android:layout_width="40dp" 
         android:layout_height="40dp" 
         android:src="@drawable/user" /> 

        <EditText 
         android:id="@+id/login_password" 
         style="@style/EditTextDark" 
         android:layout_width="fill_parent" 
         android:layout_height="wrap_content" 
         android:layout_below="@id/login_carNumber" 
         android:layout_marginTop="10dp" 
         android:layout_toRightOf="@+id/login_lock_icon" 
         android:hint="@string/prompt_password" 
         android:inputType="phone" 
         android:textAppearance="?android:attr/textAppearanceMedium" 
         android:textCursorDrawable="@null" > 
        </EditText> 

        <ImageView 
         android:id="@+id/login_lock_icon" 
         android:layout_width="40dp" 
         android:layout_height="40dp" 
         android:layout_alignTop="@id/login_password" 
         android:layout_below="@id/login_car_icon" 
         android:src="@drawable/lock" /> 

        <Button 
         android:id="@+id/sign_in_button" 
         android:layout_width="fill_parent" 
         android:layout_height="40dp" 
         android:layout_alignParentBottom="true" 
         android:layout_centerHorizontal="true" 
         android:layout_marginBottom="10dp" 
         android:background="@drawable/button_rounded" 
         android:gravity="center_horizontal" 
         android:paddingTop="5dp" 
         android:text="@string/action_sign_in_short" 
         android:textColor="#000000" /> 
       </RelativeLayout> 
      </LinearLayout> 
     </RelativeLayout> 
    </ScrollView> 


    <Button 
     android:id="@+id/quit_app_button" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:text="@string/action_exit_app" /> 

</RelativeLayout> 

======= EDIT =========

Tak, zmieniłem układ według Josephs sugestią, ale teraz "wysokość jest bardzo duża", nawet jeśli nie ma ku temu powodu, tj. przycisk na końcu jest "daleko w dół", więc musisz przewinąć "daleko w dół", aby go zobaczyć, zamiast być na dole ekranu. Mam nadzieję, że rozumiesz o co mi chodzi:

Notice the scrollbar on the right, and the button isnt seen, as it is "far down"

* Zwróć uwagę na pasek przewijania po prawej stronie, a przycisk isnt widać, jak to jest „daleko”. Ponadto, tło jest rozciągnięte, co oznaczałoby, że RelativeLayout nazwany "linearLayoyt6" (mylące, tak) z jakiegoś powodu rozwija się w dół ... *

Próbowałem ustawić wysokość na stałą dp, dla ScrollView i poniższe układy, ale nic nie pomogło.I XML jest tak:

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/ScrollView" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 

    <RelativeLayout 
     android:id="@+id/linearLayout6" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:background="@drawable/taxibg3" 
     android:orientation="vertical" > 

     <RelativeLayout 
      android:id="@+id/login_form" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      > 

      <LinearLayout 
       android:id="@+id/iv1" 
       android:layout_width="240dp" 
       android:layout_height="280dp" 
       android:layout_centerHorizontal="true" 
       android:layout_marginTop="25dp" 
       android:background="@drawable/login_square_adapted" 
       android:orientation="vertical" 
       android:paddingBottom="0dp" 
       android:paddingLeft="0dp" 
       android:paddingRight="0dp" 
       android:paddingTop="15dp" > 

       <TextView 
        android:id="@+id/textView1" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:gravity="center_horizontal" 
        android:text="@string/vehicleLogin" 
        android:textAppearance="?android:attr/textAppearanceMedium" 
        android:textColor="#ffffff" /> 

       <FrameLayout 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="3dp" 
        android:layout_marginRight="3dp" 
        android:layout_marginTop="10dp" > 

        <include layout="@layout/menu_divider_horizontal" > 
        </include> 
       </FrameLayout> 

       <RelativeLayout 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="30dp" 
        android:layout_marginRight="30dp" 
        android:layout_marginTop="35dp" 
        android:gravity="center_horizontal" 
        android:orientation="vertical" > 

        <EditText 
         android:id="@+id/login_carNumber" 
         style="@style/EditTextDark" 
         android:layout_width="fill_parent" 
         android:layout_height="wrap_content" 
         android:layout_toRightOf="@+id/login_car_icon" 
         android:hint="@string/prompt_carNumber" 
         android:inputType="phone" 
         android:textAppearance="?android:attr/textAppearanceMedium" 
         android:textCursorDrawable="@null" > 

         <requestFocus /> 
        </EditText> 

        <ImageView 
         android:id="@+id/login_car_icon" 
         android:layout_width="40dp" 
         android:layout_height="40dp" 
         android:src="@drawable/user" /> 

        <EditText 
         android:id="@+id/login_password" 
         style="@style/EditTextDark" 
         android:layout_width="fill_parent" 
         android:layout_height="wrap_content" 
         android:layout_below="@id/login_carNumber" 
         android:layout_marginTop="10dp" 
         android:layout_toRightOf="@+id/login_lock_icon" 
         android:hint="@string/prompt_password" 
         android:inputType="phone" 
         android:textAppearance="?android:attr/textAppearanceMedium" 
         android:textCursorDrawable="@null" > 
        </EditText> 

        <ImageView 
         android:id="@+id/login_lock_icon" 
         android:layout_width="40dp" 
         android:layout_height="40dp" 
         android:layout_alignTop="@id/login_password" 
         android:layout_below="@id/login_car_icon" 
         android:src="@drawable/lock" /> 
       </RelativeLayout> 

       <FrameLayout 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:layout_marginTop="30dp" 
        android:background="@drawable/login_square_half" 
        android:padding="0dp" > 

        <Button 
         android:id="@+id/sign_in_button" 
         android:layout_width="120dp" 
         android:layout_height="40dp" 
         android:layout_gravity="center_vertical|center_horizontal" 
         android:background="@drawable/button_rounded" 
         android:gravity="center_horizontal" 
         android:text="@string/action_sign_in_short" 
         android:textColor="#000000" /> 
       </FrameLayout> 
      </LinearLayout> 
     </RelativeLayout> 

     <Button 
      android:id="@+id/quit_app_button" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:text="@string/action_exit_app" /> 
    </RelativeLayout> 

</ScrollView> 

Odpowiedz

1

Spróbuj zmienić resizeMode do adjustResize i przesuwając ScrollView od wewnątrz do zewnątrz RelativeLayoutlinearLayout6 i ustawienie layout_height o RelativeLayout do wrap_content.

+0

Dzięki, ale to nie zadziałało. Cały "ekran" teraz rozszerzył się w dół, znacznie większy niż rzeczywisty ekran, rzeczy "pokrywają się" i wszelkiego rodzaju dziwne rzeczy. Runtime-errors zbyt niestety :-( – Ted

+0

Właściwie to może działać, ale problem jest taki, jak stwierdzono powyżej - obszar "w dół" jest teraz bardzo duży, tj. Nawet od początku mogę przewijać faaar w dół, gdzie znajduje się przycisk. Ale nie mogę zrozumieć, dlaczego jest tak dużo miejsca w dół ... Zobacz moją EDYCJA powyżej. – Ted

Powiązane problemy