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

Button background images off-center in android app after upgrade from 1.8 to 3.2

$
0
0

I have an app that was originally written in a much earlier version of titanium (1.8 IIRC). The app worked perfectly in the earlier version, but now that I have upgraded my install of titanium, and my android SDK, the background images for buttons are appearing beside either far to the right of the button, or literally beside the button.

Here is a code sample:

var titleBar = Ti.UI.createView({ height: '40dp', top: '0dp', backgroundColor: '#ccc' });
var hr = Ti.UI.createView({ height: '2dp', top: '40dp', backgroundColor: '#777' });
var titleLabel = Ti.UI.createLabel({ text: win.title, color: '#555' });
titleBar.add(hr);
titleBar.add(titleLabel);
 
var refresh = Ti.UI.createButton({ left: '5dp', top: '5dp', height: '30dp', width: '30dp', image: '/images/refresh.png'});
var bookmark = Ti.UI.createButton({ right: '5dp', top: '5dp', height: '30dp', width: '30dp', image: '/images/star.png' });
 
titleBar.add(bookmark);
Here is how it looks on a Nexus 4: ![Image of Buttons](http://www.tombrasinteractive.com/files/tva.jpg "Image of Buttons")

refresh.png is a 24x26 png and star.png is a 26x26 png. The original code used the image property, instead of backgroundImage, and it did not specify dp or px. I have tried specifying dp, px, changing the image to a backgroundImage, and just about every other option that comes to mind. Any suggestions you have would be appreciated.

Application Type: Mobile, Android Titanium SDK: Titanium Command-Line Interface, CLI version 3.2.3, Titanium SDK version 3.2.3.GA Platform: Android 4.4.2 ** Device: ** Nexus 4 Physical device **Host OS: ** OSX 10.8.5 **Titanium Studio: ** Titanium Studio, build: 3.2.3.201404181442 Build: jenkins-titanium-rcp-master-99 (origin/master) Date: 18 April 2014, 14:42:53


Viewing all articles
Browse latest Browse all 8068

Trending Articles



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