Quantcast
Channel: Appcelerator Developer Center Q&A Tag Feed (android)
Viewing all articles
Browse latest Browse all 7655

Titanium orientation change problem

$
0
0

Hello everyone I m developing Android app. using Titanium 3.1.3 . I have problem with orientiation change. When orientation change I want to change view height and width .but its not work. or I m searching another solution.

function FotoGaleri () {
    var self=Ti.UI.createView({
     backgroundColor:'white',   
 
    });
 
    var scrollData=[];
var imageGallery=[];
var resimWidth=100;
var resimHeight=90;
 
 
 
 
 
 var ResimScroll=Ti.UI.createScrollableView({
 
            showPagingControl:true,
 
            backgroundColor:'white',
            width:'300dp',
            height:'300dp',
        });
var GaleriScroll=Ti.UI.createScrollView({
    width:'auto',
    top:0,
    left:0,
    backgroundColor:'#123456',
    showVerticalScrollIndicator:true,
 
});
 
 
var a=0;
var GaleriTop=0;
var GaleriLeft=0;
for(var i=0; i<=130; i++){
 
    if(i%3==0){
 
       GaleriTop=5+a;
       GaleriLeft=5;        
        }
 
    if(i%3==1){
 
        GaleriTop=5+a;
        GaleriLeft=110;
 
    }
    if(i%3==2){
 
        GaleriTop=5+a;
        GaleriLeft=215;
        a=a+100;
    }
 imageGallery[i]=Ti.UI.createView({
    width:resimWidth+'dp',
    height:resimHeight+'dp',
    left:GaleriLeft+'dp',
    top:GaleriTop+'dp',
    backgroundColor:'#FE2EC8',
    id:i,
});
 
ResimClick(imageGallery[i]);
 
var label=Ti.UI.createLabel({
    text:i,
});
 imageGallery[i].add(label);
 
     GaleriScroll.add(imageGallery[i]);
      ResimScroll.views=imageGallery[i];
 
}
self.add(ResimScroll);
 
function ResimClick(resimclick){
 
    resimclick.addEventListener('click',function(){
 
     alert(resimclick.id);
 
 
 
    });
 
}
Ti.Gesture.addEventListener('orientationchange', function (ev) {
  if (Ti.Gesture.isLandscape(ev.orientation)) {
    alert('yatay');
    resimHeight=320;
 
  } else {
    alert('dikey');
    // Update your UI for portrait orientation
  }
});
 
 
self.add(GaleriScroll);
 
 
  return self;
}
module.exports=FotoGaleri;

Viewing all articles
Browse latest Browse all 7655

Trending Articles