Partage
  • Partager sur Facebook
  • Partager sur Twitter

[Android Studio] Problème de largeur d'interface

dans un ConstrainLayout

    25 août 2019 à 17:48:59

    Bonjour,

    Je suis en train de faire un démineur avec un ami et on a preeesque fini, on règle des détails de l'interface. J'ai tenté le ConstrainLayout mais je ne semble pas tout maitriser. J'ai essayé beaucoup de choses mais sans résultats.

    Cela donne ça pour le moment :

    je voudrais faire trois groupes :

    • le premier c'est les 3 7-segments collés
    • le second ce sont les trois boutons qui seraient un tout petit peu espacés les uns entre les autres
    • le dernier c'est les 3 derniers 7-segments collés

    Voilà le XML :

    <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/top_buttons_activity_grid"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:background="@drawable/inside"
            android:gravity="center"
            android:padding="@dimen/simple_border_padding">
    
    
            <ImageView
                android:id="@+id/timer_1"
                android:layout_width="0dp"
                android:layout_height="@dimen/icon_size"
                android:adjustViewBounds="true"
                android:contentDescription="@string/content_description_timer"
                app:layout_constraintDimensionRatio="h,23:13"
                app:layout_constraintEnd_toStartOf="@+id/timer_2"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:srcCompat="@drawable/time_0"
                tools:srcCompat="@drawable/time_0" />
    
            <ImageView
                android:id="@+id/timer_2"
                android:layout_width="0dp"
                android:layout_height="@dimen/icon_size"
                android:adjustViewBounds="true"
                android:contentDescription="@string/content_description_timer"
                app:layout_constraintDimensionRatio="h,23:13"
                app:layout_constraintLeft_toRightOf="@+id/timer_1"
                app:layout_constraintTop_toTopOf="parent"
                app:srcCompat="@drawable/time_0"
                tools:srcCompat="@drawable/time_0" />
    
            <ImageView
                android:id="@+id/timer_3"
                android:layout_width="0dp"
                android:layout_height="@dimen/icon_size"
                android:adjustViewBounds="true"
                android:contentDescription="@string/content_description_timer"
                app:layout_constraintDimensionRatio="h,23:13"
                app:layout_constraintStart_toEndOf="@+id/timer_2"
                app:layout_constraintTop_toTopOf="parent"
                app:srcCompat="@drawable/time_0"
                tools:srcCompat="@drawable/time_0" />
    
            <ImageButton
                android:id="@+id/game_flag_button"
                android:layout_width="0dp"
                android:layout_height="@dimen/icon_size"
                android:contentDescription="smiley button"
                android:padding="0dp"
                android:scaleType="fitCenter"
                android:src="@drawable/flag_button"
                app:layout_constraintDimensionRatio="h,1:1"
                app:layout_constraintStart_toEndOf="@+id/timer_3"
                app:layout_constraintEnd_toStartOf="@id/game_smiley_button"
                app:layout_constraintTop_toTopOf="parent"
                tools:ignore="ContentDescription,HardcodedText,RtlHardcoded"
                tools:src="@drawable/flag_button" />
    
            <ImageButton
                android:id="@+id/game_smiley_button"
                android:layout_width="0dp"
                android:layout_height="@dimen/icon_size"
                android:contentDescription="smiley button"
                android:padding="0dp"
                android:scaleType="fitCenter"
                android:src="@drawable/smiley_1"
                app:layout_constraintDimensionRatio="h,1:1"
                app:layout_constraintEnd_toStartOf="@id/game_settings_button"
                app:layout_constraintStart_toEndOf="@id/game_flag_button"
                app:layout_constraintTop_toTopOf="parent"
                tools:ignore="ContentDescription,HardcodedText,RtlHardcoded,InefficientWeight"
                tools:src="@drawable/smiley_1" />
    
            <ImageButton
                android:id="@+id/game_settings_button"
                android:layout_width="0dp"
                android:layout_height="@dimen/icon_size"
                android:contentDescription="smiley button"
                android:padding="0dp"
                android:scaleType="fitCenter"
                android:src="@drawable/cog_button"
                app:layout_constraintDimensionRatio="h,1:1"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintStart_toEndOf="@id/game_smiley_button"
                app:layout_constraintEnd_toStartOf="@id/timer_4"
                tools:ignore="ContentDescription,HardcodedText,RtlHardcoded"
                tools:src="@drawable/cog_button" />
    
    
            <ImageView
                android:id="@+id/timer_4"
                android:layout_width="28dp"
                android:layout_height="@dimen/icon_size"
                android:adjustViewBounds="true"
                android:contentDescription="@string/content_description_timer"
                app:layout_constraintDimensionRatio="h,23:13"
                app:layout_constraintEnd_toStartOf="@+id/timer_5"
                app:layout_constraintStart_toEndOf="@+id/game_settings_button"
                app:layout_constraintTop_toTopOf="parent"
                app:srcCompat="@drawable/time_0"
                tools:srcCompat="@drawable/time_0" />
    
            <ImageView
                android:id="@+id/timer_5"
                android:layout_width="28dp"
                android:layout_height="@dimen/icon_size"
                android:adjustViewBounds="true"
                android:contentDescription="@string/content_description_timer"
                app:layout_constraintDimensionRatio="h,23:13"
                app:layout_constraintEnd_toStartOf="@+id/timer_6"
                app:layout_constraintStart_toEndOf="@+id/timer_4"
                app:layout_constraintTop_toTopOf="parent"
                app:srcCompat="@drawable/time_0"
                tools:srcCompat="@drawable/time_0" />
    
            <ImageView
                android:id="@+id/timer_6"
                android:layout_width="0dp"
                android:layout_height="@dimen/icon_size"
                android:adjustViewBounds="true"
                android:contentDescription="@string/content_description_timer"
                app:layout_constraintDimensionRatio="h,23:13"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toEndOf="@+id/timer_5"
                app:layout_constraintTop_toTopOf="parent"
                app:srcCompat="@drawable/time_0"
                tools:srcCompat="@drawable/time_0" />
    
    
        </androidx.constraintlayout.widget.ConstraintLayout>

    Merci d'avance :)

    • Partager sur Facebook
    • Partager sur Twitter

    [Android Studio] Problème de largeur d'interface

    × 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