Skip to content

Commit

Permalink
Merge pull request #6293 from hieupham007/timob-15747-3_4_X
Browse files Browse the repository at this point in the history
[TIMOB-15747](3_4_X): Fix imageview scaling
  • Loading branch information
pingwang2011 committed Nov 7, 2014
2 parents 296a5ff + 1787b6c commit 9193c89
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,6 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
// so that it doesn't get the content height/width
if (!viewWidthDefined || !viewHeightDefined) {
Drawable d = imageView.getDrawable();

if (d != null) {
float aspectRatio = 1;
int w = MeasureSpec.getSize(widthMeasureSpec);
Expand All @@ -371,8 +370,9 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
int ih = d.getIntrinsicHeight();
int iw = d.getIntrinsicWidth();
if (ih != 0 && iw != 0) {
aspectRatio = ih / iw;
aspectRatio = 1f * ih / iw;
}

if (viewWidthDefined) {
maxWidth = w;
maxHeight = Math.round(w * aspectRatio);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,14 @@ public void processProperties(KrollDict d)
view.setHeightDefined(heightDefined);
}

if (d.containsKey(TiC.PROPERTY_LEFT) && d.containsKey(TiC.PROPERTY_RIGHT)) {
view.setWidthDefined(true);
}

if (d.containsKey(TiC.PROPERTY_TOP) && d.containsKey(TiC.PROPERTY_BOTTOM)) {
view.setHeightDefined(true);
}

if (d.containsKey(TiC.PROPERTY_IMAGES)) {
setImageSource(d.get(TiC.PROPERTY_IMAGES));
setImages();
Expand Down

0 comments on commit 9193c89

Please sign in to comment.