Search code examples
androidimagetitaniumappcelerator

How to stretch image in android appcelerator app to full width, but keep aspect ratio?


So I'm trying to view image in appcelerator android app, but I always get either image that fills whole screen, or image that has right aspect ration, but is not stretched to full width.

This code should show image stretched to full width, but keep aspect ratio, but it does not.

        var designView = Ti.UI.createView({
        width:Ti.UI.FILL,
        backgroundColor:"#042D40"
    });

Solution

  • You should set the height too!

    var designView = Ti.UI.createView({
        width:Ti.UI.FILL,
        height: Ti.UI.SIZE,
        backgroundColor:"#042D40"
    });
    

    Also, you should use ImageView for an image. So use the same size properties for the ImageView