Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10364] Android: Setting zIndex on views inside ScrollView doesn't work

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2013-09-10T20:48:11.000+0000
Affected Version/sRelease 3.1.0, Release 3.2.0
Fix Version/s2013 Sprint 19, 2013 Sprint 19 API, Release 3.2.0
ComponentsAndroid
Labelsparity, qe-testadded
ReporterErnesto Lage
AssigneeBiju pm
Created2012-07-17T02:27:07.000+0000
Updated2014-03-12T06:27:12.000+0000

Description

When you add two views to a scrollview and try to set zIndex on runtime, nothing happens. It works when added to a view or a window. Example code:
var win = Ti.UI.createWindow({ 
backgroundColor : "#FFF" 
}); 

var scrollview = Titanium.UI.createScrollView({ 
contentHeight : '700dp' 
}); 

var viewYellow = Titanium.UI.createView({ 
top : 10, 
left : 10, 
width : 100, 
height : 100, 
backgroundColor : 'yellow', 
zIndex : 1 
}); 

var viewRed = Titanium.UI.createView({ 
top : 60, 
left : 60, 
width : 100, 
height : 100, 
backgroundColor : 'red', 
zIndex : 2 
}); 

var buttonChange = Titanium.UI.createButton({ 
width : 120, 
height : 50, 
right : 10, 
top : 10, 
title : 'Change' 
}); 

scrollview.add(viewYellow); 
scrollview.add(viewRed); 
scrollview.add(buttonChange); 
win.add(scrollview); 

var i = 0; 

buttonChange.addEventListener('click', function() { 
if (i % 2 == 0) { 
viewYellow.setZIndex(3); 
viewRed.setZIndex(1); 
i++; 
} else { 
viewYellow.setZIndex(1); 
viewRed.setZIndex(3); 
i++; 
} 
}); 

win.open();

Comments

  1. jithinpv 2013-03-20

    When test case is loaded it shows Runtime Error Tested with Titanium Studio, build: 3.0.1.201212181159 Titanium SDK version: 3.1.0 (03/11/13 15:43 0c88429) Titanium SDK version: 3.0.2 (02/07/13 16:46 a4def81) Device: Samsung galaxy s duos Android version: 4.0.4 jithinpv
  2. Daniel Sefton 2013-05-28

    Tested and confirmed on Samsung Galaxy S2 Android 2.3.6, Ti SDK 3.1 GA and 3.2 CI. Updated test case to be runnable.
  3. Biju pm 2013-07-18

    PR :- https://github.com/appcelerator/titanium_mobile/pull/4458
  4. Paras Mishra 2013-10-23

    Setting zIndex on views inside ScrollView works fine. Verified fix on: Device : HTC desire V , Android version : 4.0.3 SDK: 3.2.0.v20131022171645 CLI version : 3.2.0 OS : MAC OSX 10.8.4 Alloy : 1.2.2 Appcelerator Studio, build: 3.2.0.201310181700 XCode : 5

JSON Source