Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10076] Android: Gradient endPoint property, when unspecified, doesn't adopt its documented default value

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2013-02-12T01:18:42.000+0000
Affected Version/sRelease 2.1.0
Fix Version/sRelease 3.1.0, 2013 Sprint 03, 2013 Sprint 04 Core, 2013 Sprint 04
ComponentsAndroid
Labelscore, exalture, module_views, qe-testadded
ReporterShawn Lipscomb
AssigneeSunila
Created2012-07-12T11:41:40.000+0000
Updated2013-09-30T09:08:13.000+0000

Description

Problem

The endPoint property of a Gradient (as seen in the documentation [here](http://docs.appcelerator.com/titanium/2.1/index.html#!/api/Gradient-property-endPoint)) is documented as defaulting to {"y": 1.0, "x": 0.0}. It does not. If left unspecified, the gradient is not applied. Also, setting y to 1.0 (as the same documentation shows) does not work...it must be set to '100%'.

Problem description

Gradient endPoint property does not work as documented and doesn't take the default value properly.

Steps to reproduce

1. Run the following code. The square is solid red. 2. Uncomment the "1st test" line and run again. The box still appears solid red. 3. Now comment back out the "1st test" line, uncomment the "2nd test" line, and run again. Now the box appears with the correct gradient. {panel:title=app.js}
var win1=Ti.UI.createWindow({
                 layout:'vertical',
                 backgroundColor:'gray',
                 exitOnClose:true,
                 navBarHidden:true
               });

var view1=Ti.UI.createView({
                  height:100,
                  width:100,
                  backgroundGradient:{type:'linear',
                                      //endPoint:{ x:0, y:1.0 },    // 1st test
                                      //endPoint:{ x:0, y:'100%' }, // 2nd test
                                      colors:[ {color:'white',
                                                offset:0.0},
                                               {color:'red',
                                                offset:1.0} ]}
                });
win1.add(view1);

win1.open();
{panel}

Expected result

A white-to-red vertical gradient box should appear at the top of the screen, but instead the box is completely red.

Additional notes

Using float values for the parameters never work: setting e.g. y=0.5 shows a completely white box. It works fine if setting is 50%.

Comments

  1. Shawn Lipscomb 2012-07-13

    Also, the documentation (link specified in "Problem" section) lacks the Android glyph to show that Gradient can be used on Android...it just shows iPhone, iPad, and MW glyphs.
  2. Hieu Pham 2012-11-06

    This is a layout issue. Re-assigning to core.
  3. Allen Yeung 2013-02-12

    PR: https://github.com/appcelerator/titanium_mobile/pull/3843
  4. Anshu Mittal 2013-03-01

    Tested with: SDK:3.1.0.v20130228145653 Studio: 3.1.0.201302252142 Device: Samsung tab(v 3.2) works as expected

JSON Source