Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6155] Android: Hiding a view and changing the height of another in a vertical layout scrollview cuts off the contentHeight early

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-08-01T04:27:12.000+0000
Affected Version/sRelease 1.8.0.1
Fix Version/sRelease 2.0.1
ComponentsAndroid
Labelsmodule_view, qe-testadded
ReporterPedro Enrique
AssigneeNeeraj Gupta
Created2011-11-11T10:16:20.000+0000
Updated2013-11-05T10:12:23.000+0000

Description

Problem:

I have a scrollView with a vertical layout and a bunch of views. Depending on the content, some of these views need to hide and the views after that one need to be repositioned.

Example code:

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

var scrollView = Ti.UI.createScrollView({
	layout:'vertical',
	contentHeight:'auto',
	top:0,bottom:0,left:0,right:0
});
win.add(scrollView);
win.open();

var len = 2;

for(var i = 0; i < len; i++){
	scrollView.add(
		Ti.UI.createView({
			top:5,
			left:20,
			right:20,
			backgroundColor:'white',
			height:80
		})
	);
}

var magicView = Ti.UI.createView({
	top:5,
	left:30,
	right:30,
	backgroundColor:'red',
	height:100
});
var viewThatWillGetPushedToTheTop = Ti.UI.createView({
	top:5,
	left:30,
	right:30,
	backgroundColor:'green',
	height:100
});

scrollView.add(magicView);
scrollView.add(viewThatWillGetPushedToTheTop);

for(var i = 0; i < len; i++){
	scrollView.add(
		Ti.UI.createView({
			top:5,
			left:20,
			right:20,
			backgroundColor:'white',
			height:80
		})
	)
}

scrollView.add(Ti.UI.createView({backgroundColor:'blue',height:100,top:10}))

setTimeout(function(){
	magicView.hide();
	viewThatWillGetPushedToTheTop.top -= magicView.height
},4000);

Explanation:

So, here we have a simple window with a scrollView. In the scrollView there are two white views, a red view, a green view, two more white views, and a blue one. After a 4 second timer, I remove the red view and push back the green view. When this happens, you'll see that the last view, the blue one (which is 100px height) will be cut off at the middle.

Comments

  1. Junaid Younus 2012-05-17

    Tested with 2.0.1GA2 on a Samsung Galaxy S2 and I'm unable to reproduce this issue. Ticket closed.
  2. Rima Umbrasas 2012-07-16

    Verified fixed on Tested on: Titanium SDK: 2.2.0.v20120716092112 Titanium Studio, build: 2.1.1.201207121732 and device Android 3.2
  3. Shyam Bhadauria 2012-08-01

    Re-opening to edit label

JSON Source