Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8482] Android: View doesn't show added components

GitHub Issuen/a
TypeBug
PriorityLow
StatusOpen
ResolutionUnresolved
Affected Version/sRelease 1.8.2, Release 2.0.1, Release 3.1.0
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterIvan Skugor
AssigneeUnknown
Created2012-04-02T04:09:39.000+0000
Updated2018-02-28T20:03:34.000+0000

Description

The problem

Components (Label and TextField in this case) added to the View are not showed on the screen in some cases.

Test case

To reproduce this issue, run the following example:
var tabGroup = Ti.UI.createTabGroup();

var tab1 = Ti.UI.createTab({
    title: 'Tab 1',
    window: Ti.UI.createWindow()
});

var tab2 = Ti.UI.createTab({
    title: 'Tab 2',
    window: Ti.UI.createWindow()
});

tabGroup.addTab(tab1);
tabGroup.addTab(tab2);


var scrollView = Ti.UI.createScrollView({
    width: '100%',
    height: '100%',
    layout: 'horizontal',
    backgroundColor: '#f00',
    contentWidth: 'auto',
    contentHeight: 'auto'
});

var view1 = Ti.UI.createView({
    width: '50%',
    height: 'auto',
    layout: 'vertical',
    top: 0,
    backgroundColor: '#00f'
});

var view2 = Ti.UI.createView({
    width: '50%',
    top: 0,
    height: 'auto',
    layout: 'vertical',
    backgroundColor: '#0f0'
});

scrollView.add(view1);
scrollView.add(view2);

for (var i = 0; i < 50; ++i) {
    
    var label = Ti.UI.createLabel({
        top: 10,
        //comment line below to see the components
        height: '10%',
        text: 'Label ' + i
    });
    
    var input = Ti.UI.createTextField({
        top: 10,
        //comment line below to see the components
        height: '10%',
        width: 200
    });
    
    view1.add(label);
    view2.add(input);
}

tab1.window.add(scrollView);

tabGroup.open();

The result

As you should see, two Views in ScrollView have 50% height and components added to them are not visible on the screen.

Expected result

All components should be visible on the screen. If component dimension defined as percentage is commented out, all components are visible on the screen. In my opinion, components should be able to use percentages for dimension definition. In this particular case, component dimension should be looked up - because View has height defined as "auto" (and ScrollView's contentHeight is set to 'auto'), component size should be determined by the size of the Window (first component higher in the hierarchy that have defined dimension value - that could also be ScrollView because it has height defined as 100%). After that, View should calculate height according to the size of their child components (View have Labels and TextFields).

Comments

  1. Varun Joshi 2012-04-02

    Tested and Confirmed this issue.
  2. Junaid Younus 2012-05-22

    Tested with 2.0.1GA2 on a Samsung Galaxy S2, issue still exists.
  3. Shameer Jan 2013-03-05

    The problem reproduce with release 3.0.2 and master release 3.1.0 tested on Titanium Studio, build: 3.0.1.201212181159 Titanium SDK version: 3.1.0 Titanium SDK version: 3.0.2 Device: Samsung galaxy s duos Android version: 4.0.4 Android Emulator: Android SDK version: 2.2 I think there exist many issues related to the "percentage" unit.

JSON Source