scrollView containing tableView layout problem on Android
Having a small issue with scrollView and vertical layouts.
If I set the scrollView contentHeight:'auto', then the VerticalScrollIndicator becomes a small blob in the top of the scroll view and the scroll length area becomes huge. In other words, the "auto" height is failing to calculate the height of the ScrollView when it contains a tableView.
Secondly, the tableView rowheight property doesnt appear to work at all. No matter what you set it to, it is always the same height.
tableView=Titanium.UI.createTableView({backgroundColor:'transparent',separatorStyle:Ti.UI.iPhone.TableViewSeparatorStyle.NONE,top:500,data:tvData});
var scrollView = Titanium.UI.createScrollView({backgroundColor:'#fff',contentWidth:parseInt(Titanium.Platform.displayCaps.platformWidth,10)-20,contentHeight:'auto',showVerticalScrollIndicator:true,top:5,borderRadius:6,borderWidth:4});
var copyright = Titanium.UI.createLabel({text: 'Copyright (C) 2010 XXX. All rights Reserved',font: {fontFamily:'Helvetica Neue',fontSize:12,fontWeight:'bold'},color:'#aaa',bottom:10,height:15,width:parseInt(Titanium.Platform.displayCaps.platformWidth), textAlign:'center'});
scrollView.add(logoImg);
scrollView.add(SummaryTxt);
scrollView.add(rescueLogoImg);
scrollView.add(rescueTxt);
scrollView.add(tableView);
scrollView.add(copyright);
Suggestions and recommendations are much appreciated.
3 Answers
-
Hey Gregor, The row height problem is definitely a bug..
The TableView takes up the entire parents viewable area by default, so what you might be seeing is the TableView exapnding the ScrollView to it's maximum height. Can you try setting the height on the tableView to see if it fixes the problem?
-
One thing I should mention – you might also want to take a look at using headerView / footerView of the table view. This allows you to pin a view (or group of views) to the table view so you don't need a "scroll inside a scroll" like you're currently setting up, which can cause strange behavior.
-
Hi Marshall,
I can set the row height and it works ok, the problem I have is that the tableview is a variable length so I guess I will have to workaround by retrieving the data, counting the number of responses and then multiplying that by the single row height.
I've also come across a null pointer exception in the same file when loading a UI.ScrollableView which I am trying to pinpoint.