Android stretching image

I am trying to get my image with the ability to draw png to fill the display (I'm not interested in relationships). However, fill_parent does not work, and as far as I know, there is no background for RelativeLayout?

Hi

RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:onClick="toggleAdvice"



   ImageView
    android:id="@+id/advice_view"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:src="@drawable/pratbubbla_gron"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
+3
source share
3 answers

I used programmatically to stretch / shring an ImageView, perhaps this piece of code will help you:

    ImageView imageView=new ImageView(context);
    imageView.setAdjustViewBounds(true);
    imageView.setImageBitmap(bitmap);
    imageView.setMaxHeight(maxHeight);
    imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    layout.addView(imageView);
+8
source

All types of browsing have android:background, including RelativeLayout. There is no need ImageView, although I see no reason why yours cannot fill in the parent.

+8
source

:           yourImageView.setScaleType(ImageView.ScaleType.FIT_XY);

+1

Source: https://habr.com/ru/post/1778106/


All Articles