Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-19796] Android: Fixed CardView Layout #7466

Merged
merged 1 commit into from Nov 30, 2015

Conversation

ashcoding
Copy link
Contributor

Jira: https://jira.appcelerator.org/browse/TIMOB-19796

Testcode:-

var win = Ti.UI.createWindow({
    backgroundColor: 'white'
});

function createCard(layout, wrap) {

    var card = Ti.UI.Android.createCardView({
        top: 20,
        height: 160,
        layout: layout
    });

    if (wrap) {

        view = Ti.UI.createView({
            layout: layout
        });

        card.add(view);

    } else {
        view = card;
    }

    view.add(Ti.UI.createLabel({
        width: 50,
        height: 100,
        backgroundColor: 'green',
        text: (wrap ? 'reference' : layout) + ' in green',
        color: 'black'
    }));

    view.add(Ti.UI.createLabel({
        top: 10,
        width: 100,
        height: 50,
        backgroundColor: 'red',
        text: (wrap ? 'reference' : layout) + ' in red',
        color: 'black'
    }));

    return card;
}

function createCardWithFill(layout, wrap) {

    var card = Ti.UI.Android.createCardView({
        top: 20,
        width: Ti.UI.FILL,
        height: 160,
        layout: layout
    });

    if (wrap) {

        view = Ti.UI.createView({
            layout: layout
        });

        card.add(view);

    } else {
        view = card;
    }

    view.add(Ti.UI.createLabel({
        width: 50,
        height: 100,
        backgroundColor: 'green',
        text: (wrap ? 'reference' : layout) + ' in green',
        color: 'black'
    }));

    view.add(Ti.UI.createLabel({
        top: 10,
        width: 100,
        height: 50,
        backgroundColor: 'red',
        text: (wrap ? 'reference' : layout) + ' in red',
        color: 'black'
    }));
    return card;
}

function createView(layout, wrap) {

    var card = Ti.UI.createView({
        top: 20,
        width: Ti.UI.FILL,
        height: 160,

        layout: layout
    });

    var view;

    if (wrap) {

        view = Ti.UI.createView({
            layout: layout
        });

        card.add(view);

    } else {
        view = card;
    }

    view.add(Ti.UI.createLabel({
        width: 50,
        height: 100,
        backgroundColor: 'green',
        text: (wrap ? 'reference' : layout) + ' in green',
        color: 'black'
    }));

    view.add(Ti.UI.createLabel({
        top: 10,
        width: 100,
        height: 50,
        backgroundColor: 'red',
        text: (wrap ? 'reference' : layout) + ' in red',
        color: 'black'
    }));

    return card;
}


var scrollView = Ti.UI.createScrollView({
    layout: 'vertical'
});

scrollView.add(createCard('horizontal'));
scrollView.add(createCardWithFill('horizontal'));
scrollView.add(createView('horizontal'));

scrollView.add(createCard('vertical'));
scrollView.add(createCardWithFill('vertical'));
scrollView.add(createView('vertical'));

scrollView.add(createCard('vertical', true));
scrollView.add(createCardWithFill('vertical', true));
scrollView.add(createView('vertical', true));

scrollView.add(createCard('composite'));
scrollView.add(createCardWithFill('composite'));
scrollView.add(createView('composite'));

win.add(scrollView);
win.open();

@FokkeZB
Copy link
Contributor

FokkeZB commented Nov 18, 2015

I'm trying to build this PR, but there must be something wrong in my environment because I get:

...
    [javac] /Users/fokkezb/dev/forks/titanium_mobile/android/modules/map/src/java/ti/modules/titanium/map/TiMapActivity.java:11: error: package com.google.android.maps does not exist
    [javac] import com.google.android.maps.MapActivity;
    [javac]                               ^
    [javac] /Users/fokkezb/dev/forks/titanium_mobile/android/modules/map/src/java/ti/modules/titanium/map/TiMapActivity.java:13: error: cannot find symbol
    [javac] public class TiMapActivity extends MapActivity
    [javac]                                    ^
    [javac]   symbol: class MapActivity
    [javac] Note: [KrollBindingGen] Generating JSON: file:/Users/fokkezb/dev/forks/titanium_mobile/dist/android/json/org/appcelerator/titanium/bindings/map.json
    [javac] 32 errors

BUILD FAILED
/Users/fokkezb/dev/forks/titanium_mobile/android/build/common.xml:592: The following error occurred while executing this line:
/Users/fokkezb/dev/forks/titanium_mobile/android/build/common.xml:681: The following error occurred while executing this line:
/Users/fokkezb/dev/forks/titanium_mobile/android/build/common.xml:683: The following error occurred while executing this line:
/Users/fokkezb/dev/forks/titanium_mobile/android/build/common.xml:660: The following error occurred while executing this line:
/Users/fokkezb/dev/forks/titanium_mobile/android/build/common.xml:548: The following error occurred while executing this line:
/Users/fokkezb/dev/forks/titanium_mobile/android/build/common.xml:286: The following error occurred while executing this line:
/Users/fokkezb/dev/forks/titanium_mobile/android/build/common.xml:228: The following error occurred while executing this line:
/Users/fokkezb/dev/forks/titanium_mobile/android/build/common.xml:174: Compile failed; see the compiler error output for details.

Total time: 11 seconds

@ashcoding
Copy link
Contributor Author

Seems like something related with GoogleMaps.

@FokkeZB
Copy link
Contributor

FokkeZB commented Nov 18, 2015

haha, yes... I figured out that much ;) Can you send me a build to test?

Btw, for the sake of parity I must say I favoured the contentView option. Then you don't need to pass on the view properties (backgroundColor, opacity, layout etc as well). But of course on the other hand this way we have more control.

@hieupham007
Copy link
Contributor

Code reviewed and functionally tested. Request accepted

hieupham007 added a commit that referenced this pull request Nov 30, 2015
[TIMOB-19796] Android: Fixed CardView Layout
@hieupham007 hieupham007 merged commit 286d0b5 into tidev:master Nov 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants