2017-10-12 8 views
1

J'ai un formulaire de connexion sur mon activité. J'ai besoin cette logique:Android. Augmenter le contenu en cliquant dans le texte d'édition

http://www.clipular.com/c/6455748191322112.png?k=Xc28Y-FsMShuNpEXbWD5rpe6faY http://www.clipular.com/c/5414772807041024.png?k=k3TB9AiHEtdV8oh6G17Ag-MS2nI

Comment puis-je faire cela? J'ai essayé de définir android:windowSoftInputMode="adjustPan" au Activity dans le manifeste, mais cela n'a pas fonctionné.

Ma mise en page:

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

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <ImageView 
     android:id="@+id/logo" 
     android:layout_width="@dimen/login_logo_width" 
     android:layout_height="@dimen/login_logo_height" 
     android:layout_marginTop="@dimen/login_logo_margin_top" 
     android:layout_marginStart="@dimen/login_logo_margin_left" 
     android:src="@drawable/logo_transfort_white" 
     android:contentDescription="@string/logo_title"/> 

    <TextView 
     android:id="@+id/skip" 
     style="@style/GrayText" 
     android:layout_width="wrap_content" 
     android:layout_height="@dimen/default_text_height" 
     android:layout_alignEnd="@id/logo" 
     android:layout_alignParentEnd="true" 
     android:layout_marginEnd="@dimen/skip_button_margin_right" 
     android:layout_marginTop="@dimen/skip_button_margin_top" 
     android:gravity="center" 
     android:text="@string/skip" /> 

    <LinearLayout 
     android:id="@+id/inputs" 
     android:background="@drawable/login_buttons_background" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="@dimen/inputs_block_margin_top" 
     android:layout_marginStart="@dimen/inputs_block_margin_left_right" 
     android:layout_marginEnd="@dimen/inputs_block_margin_left_right" 
     android:layout_below="@id/logo" 
     android:orientation="vertical" 
     android:descendantFocusability="beforeDescendants" 
     android:focusableInTouchMode="true"> 

     <EditText 
      android:id="@+id/login" 
      android:layout_width="match_parent" 
      android:layout_height="@dimen/default_text_height" 
      android:layout_marginTop="@dimen/inputs_block_margin_left_right" 
      android:layout_marginStart="@dimen/inputs_block_margin_left_right" 
      android:background="@color/text_color_white_transparent" 
      android:ems="16" 
      android:hint="@string/login" 
      style="@style/LoginInputs"/> 

     <View 
      android:id="@+id/inputs_line" 
      android:layout_width="wrap_content" 
      android:layout_height="@dimen/login_line_height" 
      android:layout_marginTop="@dimen/login_line_margin_top" 
      android:layout_marginStart="@dimen/inputs_block_margin_left_right" 
      android:layout_marginEnd="@dimen/inputs_block_margin_left_right" 
      android:background="@color/line_color_white_capacity" /> 

     <EditText 
      android:id="@+id/password" 
      android:layout_width="match_parent" 
      android:layout_height="@dimen/default_text_height" 
      android:layout_marginTop="@dimen/login_line_margin_top" 
      android:layout_marginStart="@dimen/inputs_block_margin_left_right" 
      android:layout_marginBottom="@dimen/inputs_block_margin_left_right" 
      android:background="@color/text_color_white_transparent" 
      android:ems="16" 
      android:hint="@string/password" 
      android:inputType="textPassword" 
      style="@style/LoginInputs" /> 

    </LinearLayout> 

    <TextView 
     android:id="@+id/forgot_password" 
     android:layout_width="wrap_content" 
     android:layout_height="@dimen/default_text_height" 
     android:layout_below="@id/inputs" 
     android:layout_alignParentEnd="true" 
     android:layout_marginTop="@dimen/forgot_password_margin_top" 
     android:layout_marginEnd="@dimen/inputs_block_margin_left_right" 
     android:text="@string/forgot_password" 
     android:gravity="center" 
     style="@style/WhiteText" /> 

    <Button 
     android:id="@+id/enter" 
     android:background="@drawable/sigin_button_background" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/forgot_password" 
     android:layout_centerHorizontal="true" 
     android:layout_marginStart="@dimen/inputs_block_margin_left_right" 
     android:layout_marginEnd="@dimen/inputs_block_margin_left_right" 
     android:layout_marginTop="@dimen/signin_button_margin_top" 
     android:textColor="@android:color/white" 
     android:text="@string/enter_text" /> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/enter" 
     android:orientation="horizontal"> 

     <TextView 
      android:id="@+id/no_account" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginStart="@dimen/no_account_margin_left" 
      android:layout_marginTop="@dimen/no_account_margin_top" 
      android:text="@string/no_account" 
      style="@style/GrayText"/> 

     <TextView 
      android:id="@+id/check_in" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginStart="@dimen/check_in_margin_left" 
      android:layout_marginTop="@dimen/no_account_margin_top" 
      android:text="@string/check_in" 
      style="@style/WhiteText" /> 

    </LinearLayout> 
</RelativeLayout> 

+0

faire une chose ajouter deux boutons quand vous écoutez le clavier ouvrir fermer et masquer et montrer selon le clavier ouvrir fermer – param

+0

Et encore une chose ... Je n'ai que l'image de camion, cette image sans partie noire au fond – blood73

Répondre

1

faire ScrollView en tant que parent mise en page

<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fillViewport="true"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

     // add here all your controls 

    </LinearLayout> 

</ScrollView> 

que d'utiliser

android:windowSoftInputMode="adjustPan" en vous l'activité

<activity 
    android:name=".activity.TempActivity" 
    android:windowSoftInputMode="adjustPan" 
    android:theme="@style/AppTheme.NoActionBar"/> 
+0

Ne fonctionne pas pour moi. – blood73

0

Je l'ai fait de cette façon:

<FrameLayout 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:fitsSystemWindows="true" 
android:background="@android:color/black"> 

<FrameLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:scaleType="fitCenter" 
     android:background="@drawable/truck" 
     android:contentDescription="@string/truck" /> 

    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="@dimen/auth_gradient_height" 
     android:layout_gravity="bottom" 
     android:background="@drawable/background_gradient" 
     android:contentDescription="@string/gradient" /> 
</FrameLayout> 

<View 
    android:id="@+id/overlay_view" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
</View> 

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <ImageView 
     android:id="@+id/logo" 
     android:layout_width="@dimen/login_logo_width" 
     android:layout_height="@dimen/login_logo_height" 
     android:layout_marginTop="@dimen/login_logo_margin_top" 
     android:layout_marginStart="@dimen/login_logo_margin_left" 
     android:src="@drawable/logo_transfort_white" 
     android:contentDescription="@string/logo_title"/> 

    <TextView 
     android:id="@+id/skip" 
     style="@style/GrayText" 
     android:layout_width="wrap_content" 
     android:layout_height="@dimen/default_text_height" 
     android:layout_alignEnd="@id/logo" 
     android:layout_alignParentEnd="true" 
     android:layout_marginEnd="@dimen/skip_button_margin_right" 
     android:layout_marginTop="@dimen/skip_button_margin_top" 
     android:gravity="center" 
     android:text="@string/skip" /> 

    <ScrollView 
     android:id="@+id/scroll_view" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:scrollbars="none"> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <LinearLayout 
       android:id="@+id/inputs" 
       android:background="@drawable/login_buttons_background" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="@dimen/inputs_block_margin_top" 
       android:layout_marginStart="@dimen/inputs_block_margin_left_right" 
       android:layout_marginEnd="@dimen/inputs_block_margin_left_right" 
       android:orientation="vertical" 
       android:descendantFocusability="beforeDescendants" 
       android:focusableInTouchMode="true"> 

       <EditText 
        android:id="@+id/login" 
        android:layout_width="match_parent" 
        android:layout_height="@dimen/default_text_height" 
        android:layout_marginTop="@dimen/inputs_block_margin_left_right" 
        android:layout_marginStart="@dimen/inputs_block_margin_left_right" 
        android:background="@color/text_color_white_transparent" 
        android:ems="16" 
        android:hint="@string/login" 
        style="@style/LoginInputs"/> 

       <View 
        android:id="@+id/inputs_line" 
        android:layout_width="wrap_content" 
        android:layout_height="@dimen/login_line_height" 
        android:layout_marginTop="@dimen/login_line_margin_top" 
        android:layout_marginStart="@dimen/inputs_block_margin_left_right" 
        android:layout_marginEnd="@dimen/inputs_block_margin_left_right" 
        android:background="@color/line_color_white_capacity" /> 

       <EditText 
        android:id="@+id/password" 
        android:layout_width="match_parent" 
        android:layout_height="@dimen/default_text_height" 
        android:layout_marginTop="@dimen/login_line_margin_top" 
        android:layout_marginStart="@dimen/inputs_block_margin_left_right" 
        android:layout_marginBottom="@dimen/inputs_block_margin_left_right" 
        android:background="@color/text_color_white_transparent" 
        android:ems="16" 
        android:hint="@string/password" 
        android:inputType="textPassword" 
        style="@style/LoginInputs" /> 

      </LinearLayout> 

      <TextView 
       android:id="@+id/error_message" 
       android:layout_width="wrap_content" 
       android:layout_height="@dimen/default_text_height" 
       android:layout_below="@id/inputs" 
       android:layout_marginTop="@dimen/forgot_password_margin_top" 
       android:layout_marginStart="@dimen/inputs_block_margin_left_right" 
       tools:text="@string/auth_error" 
       android:gravity="center" 
       style="@style/RedText" /> 

      <TextView 
       android:id="@+id/forgot_password" 
       android:layout_width="wrap_content" 
       android:layout_height="@dimen/default_text_height" 
       android:layout_below="@id/inputs" 
       android:layout_alignParentEnd="true" 
       android:layout_marginTop="@dimen/forgot_password_margin_top" 
       android:layout_marginEnd="@dimen/inputs_block_margin_left_right" 
       android:text="@string/forgot_password" 
       android:gravity="center" 
       style="@style/WhiteText" /> 

      <Button 
       android:id="@+id/enter" 
       android:background="@drawable/sigin_button_background" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@id/forgot_password" 
       android:layout_centerHorizontal="true" 
       android:layout_marginStart="@dimen/inputs_block_margin_left_right" 
       android:layout_marginEnd="@dimen/inputs_block_margin_left_right" 
       android:layout_marginTop="@dimen/signin_button_margin_top" 
       android:textColor="@android:color/white" 
       android:text="@string/enter_text" /> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@id/enter" 
       android:orientation="horizontal"> 

       <TextView 
        android:id="@+id/no_account" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginStart="@dimen/no_account_margin_left" 
        android:layout_marginTop="@dimen/no_account_margin_top" 
        android:text="@string/no_account" 
        style="@style/GrayText"/> 

       <TextView 
        android:id="@+id/check_in" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginStart="@dimen/check_in_margin_left" 
        android:layout_marginTop="@dimen/no_account_margin_top" 
        android:text="@string/check_in" 
        style="@style/WhiteText" /> 

      </LinearLayout> 
     </RelativeLayout> 
    </ScrollView> 
</RelativeLayout> 

Mais dans ce cas, je dois faire défiler le bouton à partir du code lorsque le clavier est afficher/masquer la