ImageView scaling: fixed height variable width with maxWidth

I'm going to show some images, but my limitation is the title. I want all images to have the same height, but according to their width, they should have different widths. I just don't want to lose part of the image when scaling. here is my code:

    <com.android.volley.toolbox.NetworkImageView
        android:id="@+id/ImageView_IssueFirstLookActivity_magas"
        android:layout_width="wrap_content"
        android:layout_height="170dp"
        android:layout_marginLeft="32dip"
        android:layout_weight="2"
        android:maxWidth="40dp"
        android:adjustViewBounds="true"
        android:scaleType="fitStart" />

      

I tried everything I could with different values android:scaleType

but didn't get anywhere. here is the figure I want, but when I play with these properties its dose does not scale, as I want for example some time when the dose does not fully display the width of the image and it degrades it greatly. Another try, for example, is that android:scaleType="fitStart"

will make my images' widths fine, but the heights don't fit anymore. Any idea?

enter image description here

+3


source to share


1 answer


Attributes

andriod ImageView doesn't support the requirement you said just statically picking the combination of width, height and saleType in the xml layout.



Instead, you can do it in java code by actually finding the image width for a given fixed height and setting them programmatically for each view to dp (make sure you do the pixel computation in dp to achieve correct output, across devices)

0


source







All Articles