2012-10-30 15 views
8

Oto układ:android miękki układ klawiatury psuje gdy pojawia

<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" > 

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" > 

     <FrameLayout 
      android:layout_width="match_parent" 
      android:layout_height="0px" 
      android:layout_weight="1" /> 

     <FrameLayout 
      android:background="#0000ff" 
      android:layout_width="match_parent" 
      android:layout_height="0px" 
      android:layout_weight="1" /> 

     <FrameLayout 
      android:layout_width="match_parent" 
      android:layout_height="0px" 
      android:layout_weight="1" /> 

    </LinearLayout> 

    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" /> 

</RelativeLayout> 

enter image description here

chcę niebieski pasek pozostać nienaruszone podczas EditText dotknięciu i pojawia się klawiatura. To znaczy. Chcę zachować jego wielkość i pozycję. Wypróbowałem wszystkie cztery możliwe wartości parametru mojej aktywności android:windowSoftInputMode w AndroidManifest. I zawsze moje niebieskie porusza bar lub kurczy w miękkiej klawiatury pojawiają:

android:windowSoftInputMode="adjustUnspecified" lub domyślnie:

enter image description here

android:windowSoftInputMode="adjustPan" lub android:windowSoftInputMode="adjustNothing":

enter image description here

android:windowSoftInputMode="adjustResize":

enter image description here

Czy możliwe jest utrzymanie tego samego rozmiaru i pozycji po pojawieniu się funkcji soft keyb?

+4

Próbowałem z 'adjustNothing' i wydaje się działać na moim urządzeniu (Google Nexus) – fiddler

Odpowiedz

1

Ponieważ dane wejściowe mają wartość EditText, zawsze będą coś przenoszone.

Należy wziąć pod uwagę dwa układy, jeden dla klawiatury, gdy jest naciśnięty, a drugi dla klawiatury.

Korzystanie z ViewSwitcher może w tym pomóc.

0

Myślę, że to z powodu LinearLayout, którego używasz. Czy możesz zmienić swój wewnętrzny układ z odpowiednim układem? W obecnej sytuacji klawiatura zmienia marginesy między komponentami ze względu na układ liniowy. I zmień konfigurację za pomocą funkcji adjustNothing.

1

musisz użyć <ScrollView> jako głównego układu. przykład:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    .... 
</ScrollView> 

lub użyć tego kodu w AndroidManifest.xml:

<activity 
    android:windowSoftInputMode="adjustNothing"> 
</activity> 
Powiązane problemy