5
I have some images inside the folder drawable
and call them via code:
public void inserindoImage(ImageView image,int rid,LinearLayout linear )
{
image.setBackgroundResource(rid);
linear.addView(image);
}
When calling this function the image goes on the screen.
and stay like this
original image
I would like to know how to make the image keep the proportion in imagemView
, as you can see there is a deformation in the image.
xml
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:id="@+id/scrollView">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearImage"
android:orientation="horizontal">
<!--Imagem vem aqui-->
</LinearLayout>
</LinearLayout>
</ScrollView>
In case I put only one, but comes more picture so the scroolView
.
After
image.setBackgroundResource(rid);
placeimage.setScaleType(ImageView.ScaleType.CENTER);
– ramaral
Are you setting any Layoutparameters for Imageview? Add all relevant code.
– ramaral
I just noticed that I made a mistake in scaleType, it is not CENTER but CENTER_INSIDE:
image.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
– ramaral
@ramaral of a look in the edition see if it becomes clearer, I tried but it did not change anything, analyzing the image it fits in the length of the screen but height did not, I needed to move in height.
– Vale