prodz18 / TiDynamicGrid

An Alloy Widget for creating a dynamic grid layout (like Pinterest) in iOS and Android.
75 stars 13 forks source link

Android layout issue #2

Closed foolprooflabs closed 10 years ago

foolprooflabs commented 10 years ago

Hi Pablo, great widget, thank you very much :)

I just had a play with it yesterday using 3.3.0.GA and TiShadow to build and made it read dynamic content from a Wordpress blog. I found that the layout gave me some issues in Android, there was quite a lot of empty space at the bottom of each view element like this:

If I changed:

var frame = Ti.UI.createView({
        width:Ti.UI.FILL,
        height:tmpView.size.height,

to:

var frame = Ti.UI.createView({
        width:Ti.UI.FILL,
        height:Ti.UI.SIZE,

and also changed:

var overlay = Ti.UI.createView({
        width:Ti.UI.FILL,
        height:Ti.UI.FILL,

to:

var overlay = Ti.UI.createView({
        width:Ti.UI.FILL,
        height:Ti.UI.SIZE,

It looks as expected:

prodz18 commented 10 years ago

Hi. Thanks for the feedback. Yes, Android is a little bit tricky. I'll try your code and commit a fix for this.

foolprooflabs commented 10 years ago

Actually after further inspection that doesn't seem like the best solution as it leaves the overlay with a height of 0 so clicking on an element doesn't open the view.

prodz18 commented 10 years ago

Exactly. Try setting the overlay like this:

var overlay = Ti.UI.createView({
        width:Ti.UI.FILL,
        height:tmpView.size.height,
        backgroundColor:'#ff0000',
        opacity:0.5,
        zIndex:1,
        data:item.data
});

You'll see the overlay in red in each item. It should cover all the item. Does it leave the white space? Also, try playing with the delayTime property, maybe adding a little bit more time.

If that doesn't do the trick, you can send me a sample code of how you are creating the layout of each item.

foolprooflabs commented 10 years ago

Eck....i'm sorry Pablo, it looks like it's a problem with running the app in TiShadow. I found that unless I explicitly set the "dp" when running with TiShadow, it ignores it so I'd explicitly set it in the widget.js file.

If I put it back to how it was and don't use TiShadow, it works fine in Android.

Possibly related to this TiShadow issue: https://github.com/dbankier/TiShadow/issues/180

foolprooflabs commented 10 years ago

Actually I found that if I:

a) implement your fix above for the overlay b) remove these lines: if (OS_ANDROID) { screenWidth /= Ti.Platform.displayCaps.logicalDensityFactor; }

that it loads fine with TiShadow and looks as expected. So looks like it's definitely related to that TiShadow issue.

prodz18 commented 10 years ago

Yes. It makes sense. The widget on Android requires "dp" as the unit to render the layout correctly. That's why all the calculation of the screen, columns and the logicalDensityFactor is used for.