0

So, what I'm trying to get is something like:

img1                  img2                  img3
                       |
                       |
     I want it to be centered in this ImageView

Though what I'm getting is something like:

img 1                 img2                  img3
 |
 | 
It is centered in this ImageView

I've read a lot of questions like this one in this site but nothing helped me! I've seen people using android:gravity="center" or android:layout_gravity="center". Nothing has helped me! I don't know what's the best option that I have. I would be grateful if someone helped me!

Here is my .xml file:

   <HorizontalScrollView
    android:id="@+id/scrlVPrincipal"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    tools:layout_editor_absoluteX="0dp">

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

        <ImageView
            android:id="@+id/imgCard1"
            android:layout_width="259dp"
            android:layout_height="390dp"
            android:layout_marginBottom="8dp"
            android:layout_marginEnd="8dp"
            android:layout_marginStart="8dp"
            android:layout_marginTop="8dp"
            android:layout_weight="1"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.504"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_bias="0.801"
            />

        <ImageView
            android:id="@+id/imgCard2"
            android:layout_width="259dp"
            android:layout_height="390dp"
            android:layout_marginBottom="8dp"
            android:layout_marginEnd="8dp"
            android:layout_marginStart="8dp"
            android:layout_marginTop="8dp"
            android:layout_weight="1"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.0"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_bias="0.8" />

        <ImageView
            android:id="@+id/imgCard3"
            android:layout_width="259dp"
            android:layout_height="390dp"
            android:layout_marginBottom="8dp"
            android:layout_marginEnd="8dp"
            android:layout_marginStart="8dp"
            android:layout_marginTop="8dp"
            android:layout_weight="1"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.0"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_bias="0.8" />

    </LinearLayout>
</HorizontalScrollView>
André Silva
  • 37
  • 1
  • 16

0 Answers0