1

I have a normal "read an article" type page with a single large photo at the top.

I'd like it to:

  • not scale larger than the source imgae
  • not be larger than the screen
  • not be CRAZY long vertically
  • side things I already have working
    • border (via padding), center crop (would rather top crop, but seems not avail)

The main issue I'm having is - I can either have it fill_parent (ie full width) OR wrap_content (ie as large as the original image). And nothing I have done so far allows the image to be normal size (ie keep from enlarging).

Is there a "norm" for this kind of thing? I'm sure there's some kind of sweet spot or combination of attributes for this that works - I just can't find them.

My current attempt:

        <ImageView
            android:id="@+id/article_photo"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@color/super_light_gray"
            android:scaleType="centerCrop"
            android:contentDescription="@string/articlePhoto"
            android:cropToPadding="true"
            android:layout_marginBottom="20dp"
            android:padding="1dp"/>
4

1 回答 1

0

你可以在Activity中编写一些代码来获取图像大小和显示大小。

如果图像尺寸超过显示尺寸设置显示宽度,如果不设置为图像尺寸。如果你想花哨,你可以找到 x 和 y 之间的比率,也可以垂直缩放。

于 2012-07-23T15:14:20.937 回答