سؤال

i recover a png file from a webserveur and i include it into an ImageView define like this :

var suivi = Titanium.UI.createImageView({
    top:"10%",
    width:"100%",
    height:"90%"
});

the problem is : the file is higher and wider than the ImageView, so it is reduce to ajust to the size of the imageview. What i want , is to keep it's size and navigate with finger into this image. Do you know how to do ? is my question enough clear or i shoud rephrase it?

هل كانت مفيدة؟

المحلول

I guess your question is how to keep the original dimensions on the image and be able to pan it around with your finger. Titanium does not have this feature natively. However there is a work around using a ScrollView instead.

var suivi = Titanium.UI.createImageView({
    top:"10%",
    width:"100%",
    height:"90%"
});
var scrollView = Ti.UI.createScrollView({
    contentWidth:'auto', 
    contentHeight:'auto', 
    top:0, 
    showVerticalScrollIndicator:true, 
    showHorizontalScrollIndicator:true,
    minZoomScale:0,
    maxZoomScale:10, 
    zoomScale:0 
});
scrollView.add(suivi);

And add the scrollView to you window.

نصائح أخرى

try this one as auto is deprecated now a days and also instead of using % you can use Ti.UI.SIZE

var imgView = Titanium.UI.createImageView({
    width:Ti.UI.SIZE,
    height:Ti.UI.SIZE
});
var scrollView = Ti.UI.createScrollView({
    contentWidth:Ti.UI.SIZE, 
    contentHeight:Ti.UI.SIZE, 
    top:0,
    showVerticalScrollIndicator:true, 
    showHorizontalScrollIndicator:true
});
scrollView.add(imgView);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top