Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Problems with convertPointToView on Android

$
0
0

Hi,

I'm creating a interactive map that should show popups when the user clicks certain areas. To calculate the position of the popup i'm using convertPointToView. This works great on iOS, but the placement of the popup is always wrong on Android.

Titanium SDK: 3.4.0.GA, Studio build: 3.4.0.201409261227,Platforms: iOS 8.0, Android 2.3.7 & 4.1.1

I have created a simple test case to show the problem. If you click the red square in the example the blue square should be placed where you click. This works on iOS but not on Android. On higher resolution Android phones (tested with 1080x1920) the popup is always off screen.

var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
 
var popView = Ti.UI.createView({
    backgroundColor : 'blue',
    width:100,
    height:100,
    visible : false
});
 
var showPopUp = function(point) {
    popView.top = point.y;
    popView.left = point.x;
    popView.show();
};
 
var view = Ti.UI.createView({
    backgroundColor:'red',
    width:100,
    height:100
});
view.addEventListener('click', function(e) {
    var point = e.source.convertPointToView({ x: e.x, y: e.y }, win);
    showPopUp(point);
});
win.add(view);
win.add(popView);
 
win.open();
Does anybody know what is causing this problem?

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>