Gradient Drawing Example In Android

Gradient Drawing Example in Android

This example shows how you can draw different gradient shapes in android.

Algorithm:

1.) Create a new project by File-> New -> Android Project name it GradientDrawingExample.

2.) Create and write following into src/GraphicsActivity.java:

 

 

 

3.) Create and write following into src/PictureLayout.java:

 

 

 

4.) Create and write following into res/drawable/line.xml:

 

 

5.) Create and write following into res/drawable/shape_1.xml:

 

 

 

6.) Create and write following into res/drawable/shape_2.xml:

 

 

 

7.) Create and write following into res/drawable/shape_3.xml:

 

 

 

8.) Create and write following into res/drawable/shape_4.xml:

 

 

 

9.) Create and write following into res/drawable/shape_5.xml:

 

 

 

10.) Write following into main.xml:

 

 

 

11.) Run for output.

Steps:

1.) Create a project named GradientDrawingExample and set the information as stated in the image.

Build Target: Android 4.0
Application Name: GradientDrawingExample
Package Name: com. example. GradientDrawingExample
Activity Name: GradientDrawingExampleActivity
Min SDK Version: 14

2.) Open GradientDrawingExampleActivity.java file and write following code there:

 

 

3.) Compile and build the project.

Output

Comments 1

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">