Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move View out of Constraint Layout

Image that I want to be cut

I want to move my ImageView so it will be half way out of the ConstraintLayout (parent one) You can imagine this as I make negative margin in my LinearLayout

What I have is an Image and it should be cut as on picture, so only button side of the image should be displayed on the actual device. Other part should be cut off.

Here is a part of my layout.

<android.support.constraint.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="wrap_content"
    android:orientation="vertical">

    <ImageView
        android:layout_width="71dp"
        android:layout_height="71dp"
        android:src="@drawable/someImage"
        app:layout_constraintTop_toTopOf="parent"/>

</android.support.constraint.ConstraintLayout>

So, is there any good way to do that?

like image 670
nutella_eater Avatar asked Dec 07 '22 15:12

nutella_eater


1 Answers

So I found the solution. Basically you need to make a translation of the image out of its container.

android:translationY="-22dp"
like image 51
nutella_eater Avatar answered Dec 11 '22 10:12

nutella_eater