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 @@ -378,6 +378,10 @@ export class Img extends ImageBase {
378378 } else {
379379 draweeView . setAspectRatio ( 0 ) ;
380380 }
381+
382+ if ( this . stretch ) {
383+ draweeView . setScaleType ( getScaleTypeAndroid ( this . stretch ) ) ;
384+ }
381385 }
382386
383387 // public initNativeView(): void {
@@ -998,3 +1002,33 @@ function getScaleType(scaleType: ScaleType) {
9981002
9991003 return null ;
10001004}
1005+
1006+ function getScaleTypeAndroid ( scaleType : ScaleType ) {
1007+ if ( isString ( scaleType ) ) {
1008+ switch ( scaleType ) {
1009+ case ScaleType . Center :
1010+ return android . widget . ImageView . ScaleType . CENTER ;
1011+ case ScaleType . AspectFill :
1012+ case ScaleType . CenterCrop :
1013+ return android . widget . ImageView . ScaleType . CENTER_CROP ;
1014+ case ScaleType . CenterInside :
1015+ return android . widget . ImageView . ScaleType . CENTER_INSIDE ;
1016+ case ScaleType . FitCenter :
1017+ case ScaleType . AspectFit :
1018+ return android . widget . ImageView . ScaleType . FIT_CENTER ;
1019+ case ScaleType . FitEnd :
1020+ return android . widget . ImageView . ScaleType . FIT_END ;
1021+ case ScaleType . FitStart :
1022+ return android . widget . ImageView . ScaleType . FIT_START ;
1023+ case ScaleType . Fill :
1024+ case ScaleType . FitXY :
1025+ return android . widget . ImageView . ScaleType . FIT_XY ;
1026+ case ScaleType . FocusCrop :
1027+ return android . widget . ImageView . ScaleType . CENTER_CROP ;
1028+ default :
1029+ break ;
1030+ }
1031+ }
1032+
1033+ return null ;
1034+ }
You can’t perform that action at this time.
0 commit comments