[TIMOB-25753] Android: ScrollView "width" ignores Ti.UI.SIZE as of 6.3.0
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-03-21T17:41:46.000+0000 |
Affected Version/s | Release 6.3.0 |
Fix Version/s | Release 7.1.1 |
Components | Android |
Labels | ScrollView, android |
Reporter | Joshua Quick |
Assignee | Joshua Quick |
Created | 2018-02-05T18:59:39.000+0000 |
Updated | 2018-03-23T11:42:48.000+0000 |
Description
*Summary:*
Setting the ScrollView "width" property to "Ti.UI.SIZE" will do a "Ti.UI.FiLL" instead as of Titanium 6.3.0.
_(This is not an issue with the "height" property. Only the "width".)_
*Code to Reproduce:*
var window = Ti.UI.createWindow();
var scrollView = Ti.UI.createScrollView(
{
layout: "vertical",
showHorizontalScrollIndicator: false,
shorVerticalScrollIndicator: true,
backgroundColor: "yellow",
width: Ti.UI.SIZE,
height: Ti.UI.FILL,
});
scrollView.add(Ti.UI.createLabel(
{
text: "Hello World",
color: "white",
backgroundColor: "blue",
width: Ti.UI.SIZE,
height: Ti.UI.SIZE,
}));
window.add(scrollView);
window.open();
*Result:*
The above code produces a yellow ScrollView. Note that the ScrollView does not auto-size itself to just fit the "Hello World" label as seen in "Screenshot-Bad.png".
*Expected Result:*
The ScrollView width should auto-size itself to fit the label as shown in "Screenshot-Good.png". This is how it worked in Titanium 6.2.2 and older versions.
*Cause:*
This bug happened when we added "RefreshControl" support. Google's Java "SwipeRefreshLayout" class does not support the "WRAP_CONTENT" setting.
*Recommended Solution:*
Modify Titanium's Java "TiSwipeRefreshLayout" onMeasure() method to handle the "WRAP_CONTENT" setting ourselves. We're already doing this in the vertical direction and we need to do the same for the horizontal.
https://github.com/appcelerator/titanium_mobile/blob/master/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiSwipeRefreshLayout.java#L76
Attachments
File | Date | Size |
---|---|---|
Screenshot-Bad.png | 2018-02-05T18:53:55.000+0000 | 42170 |
Screenshot-Good.png | 2018-02-05T18:53:59.000+0000 | 56232 |
PR (master): https://github.com/appcelerator/titanium_mobile/pull/9895 PR (7.1.x): https://github.com/appcelerator/titanium_mobile/pull/9896
Master FR passed.
FR Passed. PR's merged.
Verified in SDK Version 7.1.1.v20180322144031 and 7.2.0.v20180322112525. Test and other information can be found at: 7_1_X: https://github.com/appcelerator/titanium_mobile/pull/9896 Master: https://github.com/appcelerator/titanium_mobile/pull/9895