Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-19796

Android: CardView Layout property not working as expected

    Details

    • Type: Bug
    • Status: Closed
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: Release 5.1.0
    • Fix Version/s: Release 5.1.2
    • Component/s: Android
    • Labels:
      None
    • Environment:

      SDK 5.1.0.v20151019145227

      Description

      The new Ti.UI.CardView is documented to support the layout property - as one would expect - but it does not behave as expected.

      The following sample code and attached screenshot demonstrates that none of the layout values work and that whatever mechanism is used by default is not composite since the labels are aligned top left instead of the expected centre. The first card has a view to wrap the labels to show what I'd expect for the other vertical-card to be like. However, there as well is shows that thew view is not filling up the parent as it normally does.

      var win = Ti.UI.createWindow({
      	backgroundColor: 'white'
      });
       
      function createCard(layout, wrap) {
       
      	var card = Ti.UI.Android.createCardView({
      		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'
      	}));
       
      	view.add(Ti.UI.createLabel({
      		top: 10,
      		width: 100,
      		height: 50,
      		backgroundColor: 'red',
      		text: (wrap ? 'reference' : layout) + ' in red'
      	}));
       
      	return card;
      }
       
      var scrollView = Ti.UI.createScrollView({
      	layout: 'vertical'
      });
       
      scrollView.add(createCard('vertical', true));
      scrollView.add(createCard('composite'));
      scrollView.add(createCard('vertical'));
      scrollView.add(createCard('horizontal'));
       
      win.add(scrollView);
      win.open();
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                msamah Ashraf Abu (Inactive)
                Reporter:
                fokkezb Fokke Zandbergen
                Reviewer:
                Hieu Pham
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-20553
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Integration