Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19035] Android: Ti.UI.SIZE on ScrollableView not working

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2017-07-06T20:02:28.000+0000
Affected Version/sRelease 6.1.1
Fix Version/sRelease 6.2.0
ComponentsAndroid
Labelsn/a
ReporterEthan Chen
AssigneeGary Mathews
Created2015-06-17T09:43:38.000+0000
Updated2017-12-23T03:57:16.000+0000

Description

When I set the height Ti.UI.SIZE to the ScrollableView on Android, it will look like Ti.UI.FILL, but when I set a number for height, like '100dp', it will work. This problem was not happened on iOS.

Comments

  1. Amimul Hossain 2015-06-17

    Hello, I have tested this issue. and i was able to regenerate the issue.

    TESTING ENVIRONMENT

    Appcelerator Command-Line Interface, version 4.0.2 Titanium SDK 4.0.0.GA Appcelerator Studio, build: 4.0.1.201506021908 Android 5.0.1, 5.0.0

    CODE SAMPLE

       var win = Ti.UI.createWindow();
       
       var view1 = Ti.UI.createView({ backgroundColor:'#123', height: '300dp' });
       var view2 = Ti.UI.createView({ backgroundColor:'#246', height: '300dp' });
       var view3 = Ti.UI.createView({ backgroundColor:'#48b' ,height: '300dp'});
       
       var scrollableView = Ti.UI.createScrollableView({
       	height: Titanium.UI.SIZE,
           views:[view1,view2,view3],
           showPagingControl:true
       });
       
       win.add(scrollableView);
       win.open();
       

    OBSERVED RESULT

    Setting the height Ti.UI.SIZE to the ScrollableView on Android dose't work and response as Ti.UI.FILL, But when set a number for height, like '100dp', it will work. Everything works fine in iOS. Thanks.
  2. Ethan Chen 2015-07-02

    Any update here?
  3. Brad Ball 2015-08-04

    +1 ... Really could use a fix for this ...
  4. Iain Kettles 2016-04-20

    8 months later... A fix would be helpful!
  5. Iain Kettles 2016-05-10

    Any update?
  6. Iain Kettles 2016-11-01

    14 months later.. update?
  7. Gary Mathews 2016-11-03

    master: https://github.com/appcelerator/titanium_mobile/pull/8580
  8. Lokesh Choudhary 2016-11-30

    Verified the fix. Ti.UI.SIZE works as expected. Closing. Appc Studio : 4.8.1.201611291132 SDK Version : 6.1.0.v20161129071600 Mac OS Version : 10.12 Xcode Version : Xcode 8.1 Build version 8B62 Appc CLI AND Appc NPM : {"NPM":"4.2.9-1","CLI":"6.1.0-302"} Ti CLI : 5.0.11 Alloy : 1.9.4 Node : v4.6.0 Device: running 7.1Pixel
  9. Hani Hamadeh 2017-07-04

    This is not fully fixed, The following example with SDK 6.1.1.GA is crashing:
       var win = Ti.UI.createWindow({
               backgroundColor: 'white',
               layout: 'vertical'
           }),
           lbl_a = Ti.UI.createLabel({
               text: 'View A',
               height: Ti.UI.SIZE
           }),
           lbl_b = Ti.UI.createLabel({
               text: 'View B',
               height: 100
           }),
           view_a = Ti.UI.createView({
               backgroundColor: 'red',
               height: 100,
               width: '90%'
           }),
           view_b = Ti.UI.createView({
               backgroundColor: 'green',
               height: Ti.UI.SIZE,
               width: '90%'
           }),
           scrollable = Ti.UI.createScrollableView({
               views: [view_b, view_a],
               width: Ti.UI.FILL,
           	height: Ti.UI.SIZE,
           	top: '30dip'
           });
        
       view_a.add(lbl_a);
       view_b.add(lbl_b);
        
       win.add(scrollable);
       win.open();
       
    Crash trace:
       [ERROR] :  TiApplication: (main) [311,311] Sending event: exception on thread: main msg:java.lang.NullPointerException: Attempt to invoke virtual method 'int org.appcelerator.titanium.TiDimension.getAsPixels(android.view.View)' on a null object reference; Titanium 6.1.1,2017/06/26 16:09,undefined
       [ERROR] :  TiApplication: java.lang.NullPointerException: Attempt to invoke virtual method 'int org.appcelerator.titanium.TiDimension.getAsPixels(android.view.View)' on a null object reference
       [ERROR] :  TiApplication: 	at ti.modules.titanium.ui.widget.TiUIScrollableView$1.onMeasure(TiUIScrollableView.java:103)
       [ERROR] :  TiApplication: 	at android.view.View.measure(View.java:17430)
       [ERROR] :  TiApplication: 	at org.appcelerator.titanium.view.TiCompositeLayout.constrainChild(TiCompositeLayout.java:445)
       [ERROR] :  TiApplication: 	at org.appcelerator.titanium.view.TiCompositeLayout.onMeasure(TiCompositeLayout.java:303)
       [ERROR] :  TiApplication: 	at android.view.View.measure(View.java:17430)
       [ERROR] :  TiApplication: 	at org.appcelerator.titanium.view.TiCompositeLayout.constrainChild(TiCompositeLayout.java:445)
       [ERROR] :  TiApplication: 	at org.appcelerator.titanium.view.TiCompositeLayout.onMeasure(TiCompositeLayout.java:303)
       [ERROR] :  TiApplication: 	at android.view.View.measure(View.java:17430)
       [ERROR] :  TiApplication: 	at org.appcelerator.titanium.view.TiCompositeLayout.constrainChild(TiCompositeLayout.java:445)
       [ERROR] :  TiApplication: 	at org.appcelerator.titanium.view.TiCompositeLayout.onMeasure(TiCompositeLayout.java:303)
       [ERROR] :  TiApplication: 	at android.view.View.measure(View.java:17430)
       [ERROR] :  TiApplication: 	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
       [ERROR] :  TiApplication: 	at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
       [ERROR] :  TiApplication: 	at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
       [ERROR] :  TiApplication: 	at android.view.View.measure(View.java:17430)
       [ERROR] :  TiApplication: 	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
       [ERROR] :  TiApplication: 	at android.support.v7.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:391)
       [ERROR] :  TiApplication: 	at android.view.View.measure(View.java:17430)
       [ERROR] :  TiApplication: 	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
       [ERROR] :  TiApplication: 	at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
       [ERROR] :  TiApplication: 	at android.view.View.measure(View.java:17430)
       [ERROR] :  TiApplication: 	at android.widget.LinearLayout.measureVertical(LinearLayout.java:875)
       [ERROR] :  TiApplication: 	at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
       [ERROR] :  TiApplication: 	at android.view.View.measure(View.java:17430)
       [ERROR] :  TiApplication: 	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
       [ERROR] :  TiApplication: 	at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
       [ERROR] :  TiApplication: 	at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2560)
       [ERROR] :  TiApplication: 	at android.view.View.measure(View.java:17430)
       [ERROR] :  TiApplication: 	at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2001)
       [ERROR] :  TiApplication: 	at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1166)
       [ERROR] :  TiApplication: 	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1372)
       [ERROR] :  TiApplication: 	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1054)
       [ERROR] :  TiApplication: 	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5779)
       [ERROR] :  TiApplication: 	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
       [ERROR] :  TiApplication: 	at android.view.Choreographer.doCallbacks(Choreographer.java:580)
       [ERROR] :  TiApplication: 	at android.view.Choreographer.doFrame(Choreographer.java:550)
       [ERROR] :  TiApplication: 	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
       [ERROR] :  TiApplication: 	at android.os.Handler.handleCallback(Handler.java:739)
       [ERROR] :  TiApplication: 	at android.os.Handler.dispatchMessage(Handler.java:95)
       [ERROR] :  TiApplication: 	at android.os.Looper.loop(Looper.java:135)
       [ERROR] :  TiApplication: 	at android.app.ActivityThread.main(ActivityThread.java:5221)
       [ERROR] :  TiApplication: 	at java.lang.reflect.Method.invoke(Native Method)
       [ERROR] :  TiApplication: 	at java.lang.reflect.Method.invoke(Method.java:372)
       [ERROR] :  TiApplication: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
       [ERROR] :  TiApplication: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
       
  10. Gary Mathews 2017-07-04

    master: https://github.com/appcelerator/titanium_mobile/pull/9192
  11. Hani Hamadeh 2017-07-05

    Gary I tested the commit and the app is not crashing but the scrollable view didn't resize correctly. Did it resize it for you ? Thanks a lot!
  12. Samir Mohammed 2017-08-08

    Verified Fix in SDK Version: 6.2.0.v20170808135421 Test and other information can be found at: https://github.com/appcelerator/titanium_mobile/pull/9192
  13. Joshua Quick 2017-12-23

    [~hini], the fix for [TIMOB-25626] involves refactoring the Ti.UI.SIZE handing of the ScrollableView for both width and height. It will likely resolved the remaining sizing edge-cases left. This fix is currently scheduled for Titanium 7.1.0, so, stay tuned.

JSON Source