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-17361] Android: Initial CardView support #7256

Merged
merged 2 commits into from Oct 7, 2015

Conversation

ashcoding
Copy link
Contributor

@ashcoding
Copy link
Contributor Author

App.js test code:

Note: A png 'square.png' is used in this test code.

var win = Ti.UI.createWindow({
  backgroundColor: 'white',
  layout: 'vertical',
  title: 'Card View Demo'
});

///////////////////////////

var win1 = Ti.UI.createWindow({
  backgroundColor:'white',
  title: 'Card Demo 1'
});

function createRow(i) {
    var card1 = Ti.UI.Android.createCardView({
      contentPadding: 20,
      cardCornerRadius: 10,
      cardUseCompatPadding: true

    });

    var internalView = Titanium.UI.createView({
    }); 

    var label1 = Ti.UI.createLabel({    
      top:5,
      color:'black',
      text: 'Below this is a purple square',
    });
    internalView.add(label1);

    var image = Ti.UI.createImageView({
      top:50,
      image:'square.png'
    });
    internalView.add(image);

    card1.add(internalView);

    return card1;
}

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

for(var i = 0; i <= 20; i++){
var row = createRow(i);
  scrollView.add(row);
}
win1.add(scrollView);

/////////////////////////////

var win2 = Ti.UI.createWindow({
  backgroundColor: 'white',
  layout: 'vertical',
  title: 'Card Demo 2'
});

var card1 = Ti.UI.Android.createCardView({
  top: 30,
  contentPadding: 50,
  cardElevation: 40,
  cardBackgroundColor: 'yellow',
  cardCornerRadius: 120,
  width: 250, height: 200
});

var label1 = Ti.UI.createLabel({

  color:'blue',
  text: 'A long label with\na few line breaks\nand unicode (UTF8)\nsymbols such as\na white chess piece \u2655\nand the euro symbol \u20ac\nlooks like this!\n',
  textAlign: Ti.UI.TEXT_ALIGNMENT_LEFT,

});

card1.add(label1);

var card2 = Ti.UI.Android.createCardView({
  top: -80,
  contentPadding: 200,  
  cardBackgroundColor: 'red',
  cardCornerRadius: 20,
  width: 300, height: 200
});


var image = Ti.UI.createImageView({
  image:'square.png'
});

card2.add(image);

var card3 = Ti.UI.Android.createCardView({
  top: -80,
  width: 100, height: 100
});

var label2 = Ti.UI.createLabel({

  color:'black',
  text: 'Let there be text',
  textAlign: Ti.UI.TEXT_ALIGNMENT_LEFT,

});

card3.add(label2);

win2.add(card1);
win2.add(card2);
win2.add(card3);

/////////////////

var button1 = Titanium.UI.createButton({
   title: 'Demo 1',
   top: 10,
   width: 100,
   height: 50
});
button1.addEventListener('click',function(e)
{
  win1.open();
});


var button2 = Titanium.UI.createButton({
   title: 'Demo 2',
   top: 10,
   width: 100,
   height: 50
});
button2.addEventListener('click',function(e)
{
  win2.open();
});

win.add(button1);
win.add(button2);
win.open();

@@ -0,0 +1,33 @@
int attr cardBackgroundColor 0x7f010000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this? It's a generated file.

@ashcoding
Copy link
Contributor Author

Removed R.txt

@hieupham007
Copy link
Contributor

Code reviewed and functionally tested. Request accepted. Is this ready to be merged?

@ashcoding
Copy link
Contributor Author

Yup. This is ready to be merged if everything is okay.

hieupham007 added a commit that referenced this pull request Oct 7, 2015
[TIMOB-17361] Android: Initial CardView support
@hieupham007 hieupham007 merged commit a73d539 into tidev:master Oct 7, 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

2 participants