开发者

Trimming ImageView in Android

开发者 https://www.devze.com 2023-03-02 02:43 出处:网络
I have an image which is 450px square below some text in a linear layout and wanted it to fill the width of the device, which I done by using;

I have an image which is 450px square below some text in a linear layout and wanted it to fill the width of the device, which I done by using;

ImageView android:id="@+id/my_image_container"
android:src="@drawable/my_image"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/orange"
android:scaleType="fitStart"

This has worked in a fashion, but the ImageView element fills the rest of the screen and any elements placed under do not show.

Does anyone know of a way to trim the bottom of the space that the ImageView uses.

Hopefully this image can explain it better - I want to crop the empty area under the im开发者_运维问答age (orange background).

Trimming ImageView in Android


I recommend you to use a RelativeLayout instead of a LinearLayout. You can then use android:layout_above="" and android:layout_below="" to ensure that you get the layout you want.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号