sample image
So basically I want to archive something like the image above, where there are two images placed next to each other responsively for all screen size while maintain the same image ratio. Does someone have any solutions?
Thank you.
This is what I’ve done but it severely image the performance.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="12dp"
android:layout_marginTop="15dp"
android:orientation="horizontal">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/imgPickup"
android:layout_width="match_parent"
android:layout_height="0dp"
android:scaleType="fitStart"
android:src="@drawable/ic_pickup"
app:layout_constraintDimensionRatio="h, 0.895"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
style="@style/boldTextSize16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Pickup"
app:layout_constraintEnd_toEndOf="@id/imgPickup"
app:layout_constraintStart_toStartOf="@id/imgPickup"
app:layout_constraintTop_toBottomOf="@id/imgPickup" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/imgDelivery"
android:layout_width="match_parent"
android:layout_height="0dp"
android:scaleType="fitEnd"
android:src="@drawable/ic_delivery"
app:layout_constraintDimensionRatio="h, 0.895"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
style="@style/boldTextSize16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Delivery"
app:layout_constraintEnd_toEndOf="@id/imgDelivery"
app:layout_constraintStart_toStartOf="@id/imgDelivery"
app:layout_constraintTop_toBottomOf="@id/imgDelivery" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
New contributor
Chenghout is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.