Search code examples
titaniumtableviewappceleratorandroid-4.0-ice-cream-sandwich

Appcelerator titanium TableView with Android 4.x zoomed out


I am working on appcelerator titanium. After I copied almost the same code in KitchenSink to do a tableview, I ended up with a zoomed out TableView when i display it in my device ( android 4 on Galaxy Nexus ). Zoomed out means font and images are really small. What's weird is: 1- it displayed just right in the android emulator 2- it displayed just right in my android device but using KitchenSink What can be the problem ? here is the code for that part:

    if (Ti.Platform.name == 'android') 
{
    Titanium.UI.currentWindow.backgroundColor = '#4e5c4d';
}
else
{
    Titanium.UI.currentWindow.backgroundColor = '#aebcad';
}

// create table view data object
var data = [

    {title:'Table View (Layout 2)', hasChild:true, test:'../main_windows/profile.js'}
];


// create table view
var tableViewOptions = {
        data:data,
        style:Titanium.UI.iPhone.TableViewStyle.GROUPED,
        headerTitle:'TableView examples and test cases',
        footerTitle:"Wow. That was cool!",
        backgroundColor:'transparent',
        rowBackgroundColor:'white'

    };


var tableview = Titanium.UI.createTableView(tableViewOptions);

// create table view event listener
tableview.addEventListener('click', function(e)
{
    if (e.rowData.test)
    {
        var win = Titanium.UI.createWindow({
            url:e.rowData.test,
            title:e.rowData.title
        });
        Titanium.UI.currentTab.open(win,{animated:true});
    }
});

// add table view to the window
Titanium.UI.currentWindow.add(tableview);

Solution

  • SOLVED:

    I had to change the tiapp.xml file and add the line:

        <supports-screens android:anyDensity="false"/>
    

    in the android mainfest section so it is now:

    <android xmlns:android="http://schemas.android.com/apk/res/android">
        <manifest>
                <supports-screens android:anyDensity="false"/>
    
            </manifest>
    
    </android>