Gradient View in Sketchware



In this topic I will show you how to use gradient class easily in sketchware

In your project import this 

android.graphics.drawable.GradientDrawable
Then add this code :

int[] colors = {Color.parseColor("#008000"),Color.parseColor("#ADFF2F")}; //create a new gradient color GradientDrawable gd = new GradientDrawable( GradientDrawable.Orientation.TOP_BOTTOM, colors); gd.setCornerRadius(0f); //apply the button background to newly created drawable gradient view.setBackground(gd);


If you want to change the direction of gradient the choose one of this :

        *//** draw the gradient from the top to the bottom *//*
        TOP_BOTTOM,
        *//** draw the gradient from the top-right to the bottom-left *//*
        TR_BL,
        *//** draw the gradient from the right to the left *//*
        RIGHT_LEFT,
        *//** draw the gradient from the bottom-right to the top-left *//*
        BR_TL,
        *//** draw the gradient from the bottom to the top *//*
        BOTTOM_TOP,
        *//** draw the gradient from the bottom-left to the top-right *//*
        BL_TR,
        *//** draw the gradient from the left to the right *//*
        LEFT_RIGHT,
        *//** draw the gradient from the top-left to the bottom-right *//*
        TL_BR,

Comments

Popular posts from this blog

Read Json file from asset in Sketchware Pro

Change wallpaper Programmatically Sketchware

Web Scraping With Jsoup in Sketchware