I would like to know how can I crop a ImageView
that have a scaled background image using a fixed width and height on it's parent
.
Basically, I want an image to be scaled using ImageView android:background
and then I want to crop the portion of the image that is outside the parent's bounds.
Until now, I have this code:
<RelativeLayout android:id="@+id/time_foregrd"
android:layout_width="57px"
android:layout_height="100px"
android:layout_marginLeft="100px"
android:layout_marginTop="285px"
android:clipChildren="true"
>
<ImageView android:layout_width="57px"
android:layout_height="338px"
android:minWidth="57px"
android:minHeight="338px"
android:background="@drawable/time_foreground"
/>
</RelativeLayout>
But it doesn't work... What am I doing wrong?
Ok, I managed how to do that. Instead of using RelativeLayout
, I used FrameLayout
and it worked perfectly.
Here's the code:
<FrameLayout android:id="@+id/time_foregrd"
android:layout_width="57px"
android:layout_height="100px"
android:layout_marginLeft="100px"
android:layout_marginTop="285px"
>
<ImageView android:layout_width="57px"
android:layout_height="338px"
android:layout_gravity="bottom"
android:scaleType="fitXY"
android:src="@drawable/time_foreground"
/>
</FrameLayout>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With