Partage
  • Partager sur Facebook
  • Partager sur Twitter

Cours sur Firebase, checkbox du profil invisible

    5 juin 2018 à 18:55:47

    Bonjour je suis actuellement le cours sur le backend avec Firebase et la checkbox "Etes vous un mentor ?" sur la ProfileActivity est invisible sur smartphone (Nexus 5) mais est présente sur tablette (Nexus 9).

    Le layout est donné au début du cours et je l'ai pas modifié (la checkbox est au milieu):

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout 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"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        tools:context="com.openclassrooms.firebaseoc.auth.ProfileActivity"
        android:orientation="vertical"
        android:gravity="center_horizontal">
    
        <!-- USER DATA CONTAINER -->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:orientation="vertical"
            android:layout_weight="1">
    
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:layout_margin="@dimen/default_large_margin">
    
                <!-- FIREBASE IMAGE -->
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@drawable/ic_logo_auth"/>
    
                <!-- PROGRESS BAR -->
                <ProgressBar
                    android:id="@+id/profile_activity_progress_bar"
                    android:layout_width="30dip"
                    android:layout_height="30dip"
                    android:visibility="invisible"
                    android:layout_margin="@dimen/default_large_margin"/>
    
                <!-- PROFILE IMAGE -->
                <ImageView
                    android:id="@+id/profile_activity_imageview_profile"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    app:srcCompat="@drawable/ic_anon_user_48dp"/>
    
            </LinearLayout>
    
    
            <!-- PROFILE USERNAME -->
            <android.support.design.widget.TextInputEditText
                android:id="@+id/profile_activity_edit_text_username"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textSize="@dimen/default_text_size"
                android:text="@string/text_input_username"
                android:layout_margin="@dimen/default_margin"/>
    
            <!-- PROFILE EMAIL CONTAINER -->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:layout_margin="@dimen/default_margin">
    
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/text_view_email"
                    android:textSize="@dimen/default_text_size"
                    android:textStyle="bold"/>
    
                <!-- PROFILE EMAIL -->
                <TextView
                    android:id="@+id/profile_activity_text_view_email"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:textSize="@dimen/default_text_size"
                    android:paddingLeft="@dimen/default_margin"/>
    
            </LinearLayout>
    
            <!-- CHECKBOX IS USER MENTOR -->
            <CheckBox
                android:id="@+id/profile_activity_check_box_is_mentor"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/check_box_is_mentor"/>
    
        </LinearLayout>
    
        <!-- BUTTONS CONTAINER -->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="bottom"
            android:orientation="vertical"
            android:layout_weight="1">
    
            <!-- BUTTON UPDATE USERNAME -->
            <Button
                android:id="@+id/profile_activity_button_update"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/button_update_account"
                android:textColor="#fff"
                android:textSize="@dimen/default_text_size"
                android:background="@drawable/button_radius_primary_color"
                style="?android:attr/borderlessButtonStyle"
                android:layout_margin="@dimen/default_margin"
                android:padding="@dimen/default_margin"/>
    
            <!-- BUTTON SIGN OUT -->
            <Button
                android:id="@+id/profile_activity_button_sign_out"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/button_sign_out_account"
                android:textColor="#fff"
                android:textSize="@dimen/default_text_size"
                android:background="@drawable/button_radius_accent_color"
                style="?android:attr/borderlessButtonStyle"
                android:layout_margin="@dimen/default_margin"
                android:padding="@dimen/default_margin"/>
    
            <!-- BUTTON DELETE ACCOUNT -->
            <Button
                android:id="@+id/profile_activity_button_delete"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/button_delete_account"
                android:textColor="#fff"
                android:textSize="@dimen/default_text_size"
                android:background="@drawable/button_radius_error_color"
                style="?android:attr/borderlessButtonStyle"
                android:layout_margin="@dimen/default_margin"
                android:padding="@dimen/default_margin"/>
    
        </LinearLayout>
    
    </LinearLayout>
    

    Quand je passe l'édition du layout en mode Design ça donne ça: 

    Et quand j'étire manuellement le layout du dessus la checkbox apparait, mais j'imagine que c'est pas l'idéal de fixer la hauteur du layout en valeur absolu:

    Qu'est-ce qui se passe et comment je rectifie ça ? Merci !

    -
    Edité par Alban Fontaine 5 juin 2018 à 18:57:01

    • Partager sur Facebook
    • Partager sur Twitter
      6 juin 2018 à 8:55:19

      Salut,

      Ce que je te conseille de faire c'est tout simplement de retravailler le layout avec un ConstraintLayout. Ca va aplanir la hiérarchie des vues et ça s'adaptera beaucoup mieux aux différents form factors :) 

      • Partager sur Facebook
      • Partager sur Twitter

      Cours sur Firebase, checkbox du profil invisible

      × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
      × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
      • Editeur
      • Markdown