Nativescript: [Bug] The linear gradient is not correctly applied in Android

Created on 11 Jul 2018  路  8Comments  路  Source: NativeScript/NativeScript

The below-attached CSS snippet with linear gradient will not be applied correctly for Android.
XML:

 <StackLayout>
        <Label text="Linear gradient" class="h1 text-center"/>
        <StackLayout  class="test" ></StackLayout>
    </StackLayout>

CSS:

.test {   
    width:24;  
    height: 200;  
    background: linear-gradient(to top, white 50%, green);
}

Android result:
screen shot 2018-07-11 at 10 13 25 am

Expected result:
screen shot 2018-07-11 at 10 09 24 am


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

backlog bug help wanted android low

All 8 comments

% doesn't seem to be working at all, not even for IOS.

Hi @btaluy,
I tested the code in a sample project it seems to work as expected. For your convenience, I am attaching sample project and screenshot.

Archive.zip
screen shot 2018-07-23 at 11 56 44 am

50% is already what it is at default, try 10%. @tsonevn

HI @btaluy,
I tested the gradient with 10%, however, the color still seems to be applied correctly. I checked the project on iOS 11.4.
I am attaching an image with the results from the NativeScript and web demos.
screen shot 2018-07-24 at 11 42 41 am

Let me know if I am missing something.

It seems that percents are not handled correctly at all. It might be an issue with parsing.

Any news on this matter?

I just discovered that when adding the percentage, you have to add it to all colors. So instead of
background: linear-gradient(to top, white 50%, green);
you should do:
background: linear-gradient(to top, white 50%, green 0%);
This will create a solid white for the first 50%, then the gradient is applied, and in this case there is no part of solid green, so the gradient proceeds until the end of the element. If you want a larger portion of green, you should up that percentage. In CSS the 0% is optional, but Nativescript requires it.

I tested this with NS 5.3.2, on iOS 12, Android 24 and Android 28.

@Johanneke it works! Thanks

Was this page helpful?
0 / 5 - 0 ratings