File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -369,6 +369,10 @@ export class Img extends ImageBase {
369369 } else {
370370 draweeView . setAspectRatio ( 0 ) ;
371371 }
372+
373+ if ( this . stretch ) {
374+ draweeView . setScaleType ( getScaleTypeAndroid ( this . stretch ) ) ;
375+ }
372376 }
373377
374378 // public initNativeView(): void {
@@ -983,3 +987,33 @@ function getScaleType(scaleType: ScaleType) {
983987
984988 return null ;
985989}
990+
991+ function getScaleTypeAndroid ( scaleType : ScaleType ) {
992+ if ( isString ( scaleType ) ) {
993+ switch ( scaleType ) {
994+ case ScaleType . Center :
995+ return android . widget . ImageView . ScaleType . CENTER ;
996+ case ScaleType . AspectFill :
997+ case ScaleType . CenterCrop :
998+ return android . widget . ImageView . ScaleType . CENTER_CROP ;
999+ case ScaleType . CenterInside :
1000+ return android . widget . ImageView . ScaleType . CENTER_INSIDE ;
1001+ case ScaleType . FitCenter :
1002+ case ScaleType . AspectFit :
1003+ return android . widget . ImageView . ScaleType . FIT_CENTER ;
1004+ case ScaleType . FitEnd :
1005+ return android . widget . ImageView . ScaleType . FIT_END ;
1006+ case ScaleType . FitStart :
1007+ return android . widget . ImageView . ScaleType . FIT_START ;
1008+ case ScaleType . Fill :
1009+ case ScaleType . FitXY :
1010+ return android . widget . ImageView . ScaleType . FIT_XY ;
1011+ case ScaleType . FocusCrop :
1012+ return android . widget . ImageView . ScaleType . CENTER_CROP ;
1013+ default :
1014+ break ;
1015+ }
1016+ }
1017+
1018+ return null ;
1019+ }
You can’t perform that action at this time.
0 commit comments