Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save amodkanthe/cf8ce4aaf9532ebed065d764bcce69ea to your computer and use it in GitHub Desktop.
Save amodkanthe/cf8ce4aaf9532ebed065d764bcce69ea to your computer and use it in GitHub Desktop.
ImageView Ratio XML
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
android:scaleType="centerCrop"
android:src="@drawable/ic_launcher_background"
app:layout_constraintHeight_percent="0.4"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment