android - ImageView diffrent scale types for orientation -
i use imageview
has display after following rules:
- always show full width landscape , portrait images -this works now
- if image landscape image center in screen - works
- if image portrait show top - don't cut top - not work
from xml file
<imageview android:id="@+id/myimage" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_centervertical="true" android:contentdescription="@null" android:scaletype="centercrop" />
can set properties image show correct if portrait or landscape image?
you may subclass imageview
, use matrix
scaling , override setframe
method. depending on image size - whether has portrait or landscape orientation - apply different matrix. please find example implementation here aligns image bottom edge , crops off top. similar requirements might starting point further adjustments.
Comments
Post a Comment