Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-6586

Android - Add support for repeating backgrounds on a view that is similar to background-repeat property in CSS

    Details

      Description

      PROBLEM
      A customer wants to create titled backgrounds, so they look the same in any platform, and they don't have to generate different background images for each different platform.

      There is a screenshot showing the expected behavior. Additionally, you can see an example of code that will do the same effect, using insane amount of memory:

      titledapp.js

      win = Ti.UI.createWindow();
       
      var background = Ti.UI.createView();
       
      var image1 = Ti.UI.createImageView({
       // use whatever image you have here
        image: 'appicon.png',
        height: 'auto',
        width: 'auto'
      });
       
      var width=image1.size.width;
      var height=image1.size.height;
       
      var deviceW= Titanium.Platform.displayCaps.platformWidth;
      var deviceH= Titanium.Platform.displayCaps.platformHeight;
       
      var repeatX = (deviceW % width) + 1; 
      var repeatY = (deviceH % height) + 1; 
       
       
      for(i=0;i<repeatX; i++)
      	for(j=0;j<repeatY; j++){
      		background.add(Ti.UI.createImageView({
      			image: 'appicon.png',
      			height: 'auto',
      			width: 'auto',
      			top:j*height, 
      			left:i*width,
      		}));
      	}
      	
      win.add(background);
      win.open();
      
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                opiecyrus Opie Cyrus
                Reporter:
                jhaynie Jeff Haynie (Inactive)
              • Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Git Source Code