'Constraint Layout ImageView position different in device and android studio
This is the code of an xml layout which I am using as an recycler view item layout.
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:background="@color/app_background">
<ImageView
android:id="@+id/statusImage"
statusIcon="@{asteroid.potentiallyHazardous}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_status_normal" />
<TextView
android:id="@+id/approachDate"
android:text="@{asteroid.closeApproachDate}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/text_grey"
android:layout_marginTop="6dp"
app:layout_constraintStart_toStartOf="@+id/codeName"
app:layout_constraintTop_toBottomOf="@+id/codeName"
tools:text="2022-02-08"
/>
<TextView
android:id="@+id/codeName"
android:text="@{asteroid.codename}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textColor="@color/default_text_color"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="68347 (2001 KB67)"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
The problem is that, in android studio the image view is shown at the right side of the layout but when it's rendered on a device it's not the same. Any reason why this is happening?
Screenshot from android studio:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|


