make an image size to be certain percent from the screen size

Viewed 9061

In constraint layout if I want the image to be in the center horizontally and at the top of the screen, then I can do this

<android.support.constraint.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="10dp">
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/image"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            android:id="@+id/imageView" />
</android.support.constraint.ConstraintLayout>

How can I make the image width and height to be 25% of the screen width and height? Is this doable?

Thank you

3 Answers
Related