Enlarge the image of an ImageView within a Layout on Android

1

I use Picasso to download an image from the internet and load the result into an ImageView that is inside a Layout. The problem that I face is that the image does not occupy the entire size of the Layout and it fits on one side and small.

Java Code:

ImageView graph = (ImageView) findViewById(R.id.graphImageView);
Picasso.with(this).load("https://www.google.com/finance/getchart?q=INTC&p=20Y&i=86400").into(graph);

XML:

    <LinearLayout
    android:id="@+id/graphLinearLayout"
    android:layout_width="wrap_content"
    android:layout_height="343dp"
    android:layout_below="@+id/activityStockLinearLayout"
    android:orientation="horizontal">

    <ImageView
        android:id="@+id/graphImageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    </LinearLayout>

I may miss some parameter in the XML that refers to the ImageView and manages to make it occupy all the size of the frame that the Layout provides to the ImageView. I have tried to change the wrap_content parameter to match_parent but I can not do it ....

    
asked by Eduardo 24.05.2017 в 14:08
source

2 answers

3

If your container has a% high% defined, the contained elements can only be displayed in this area, this is why your image does not look bigger , consider changing the High of your 343dp to a larger measure or define:

android:layout_height="match_parent"

and obviously your LinearLayout would have the properties:

 android:layout_width="match_parent"
 android:layout_height="match_parent"
    
answered by 24.05.2017 / 17:20
source
0

In the end, solve the problem by leaving the XML in this way:

<LinearLayout
    android:id="@+id/graphLinearLayout"
    android:layout_width="match_parent"
    android:layout_height="353dp"
    android:layout_below="@+id/activityStockLinearLayout"
    android:orientation="horizontal">

    <ImageView
        android:id="@+id/graphImageView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</LinearLayout>
    
answered by 25.05.2017 в 09:23