[TinyTut] How to make a gradient window?

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

[TinyTut] How to make a gradient window?

Postby tum0rc0re » Mon Jan 14, 2008 9:19 am

Image

Code:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package maximyudin.gradientsample;
  2. import android.app.Activity;
  3. import android.os.Bundle;
  4. import android.graphics.drawable.GradientDrawable;
  5. import android.graphics.drawable.GradientDrawable.Orientation;
  6. import android.graphics.Color;
  7.  
  8. public class GradientSample extends Activity {
  9.   @Override
  10.   public void onCreate(Bundle icicle) {
  11.     super.onCreate(icicle);
  12.     setContentView(R.layout.main);
  13.  
  14.     GradientDrawable grad = new GradientDrawable(
  15.       Orientation.TOP_BOTTOM,
  16.       new int[] {Color.RED, Color.YELLOW}
  17.     );
  18.  
  19.     this.getWindow().setBackgroundDrawable(grad);
  20.   }
  21. }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4
JQ Soft web page:
[b][url=http://jqsoft.ru/]http://jqsoft.ru/[/url][/b]
My proffesional blog: [b][url=http://maximyudin.blogspot.com]http://maximyudin.blogspot.com[/url][/b]
Facebook: [b][url=http://www.facebook.com/maxim.yudin]http://www.facebook.com/maxim.yudin[/url][/b]
User avatar
tum0rc0re
Senior Developer
Senior Developer
 
Posts: 158
Joined: Sun Nov 25, 2007 7:15 am
Location: Moscow, Russia

Top

Postby venkat » Wed Jan 16, 2008 6:29 am

Thanks tum0rc0re, Good work
Regards,
Venkat.
venkat
Senior Developer
Senior Developer
 
Posts: 152
Joined: Tue Nov 27, 2007 5:42 am
Location: India

Postby xirgonium » Mon Apr 28, 2008 5:06 pm

Great !

but do you have an idea on how to define it on an XML resource file ? I can't find any information (!!)

Thx
xirgonium
Junior Developer
Junior Developer
 
Posts: 10
Joined: Thu Apr 10, 2008 6:17 pm

Postby tum0rc0re » Mon Apr 28, 2008 5:14 pm

xirgonium wrote:Great !

but do you have an idea on how to define it on an XML resource file ? I can't find any information (!!)

Thx


I don't know unfortunately.
JQ Soft web page:
[b][url=http://jqsoft.ru/]http://jqsoft.ru/[/url][/b]
My proffesional blog: [b][url=http://maximyudin.blogspot.com]http://maximyudin.blogspot.com[/url][/b]
Facebook: [b][url=http://www.facebook.com/maxim.yudin]http://www.facebook.com/maxim.yudin[/url][/b]
User avatar
tum0rc0re
Senior Developer
Senior Developer
 
Posts: 158
Joined: Sun Nov 25, 2007 7:15 am
Location: Moscow, Russia

Postby arams » Thu May 21, 2009 7:13 am

Good Work.....tum0rc0re


Works Fine....
arams
Experienced Developer
Experienced Developer
 
Posts: 89
Joined: Fri May 08, 2009 7:45 am

Re: [TinyTut] How to make a gradient window?

Postby tannerresearch » Thu Oct 07, 2010 6:04 pm

Xml gradient should be something like this:

Code: Select all
<shape xmlns:android="http://schemas.android.com/apk/res/android">
   <gradient
      android:startColor="#85a2c1"
      android:endColor="#5f8ec1"
      android:angle="270"/>
</shape>
User avatar
tannerresearch
Junior Developer
Junior Developer
 
Posts: 21
Joined: Wed Jan 07, 2009 6:43 pm

Top

Re: [TinyTut] How to make a gradient window?

Postby tannerresearch » Thu Oct 07, 2010 6:05 pm

and then you use the resource the same way you would a drawable
User avatar
tannerresearch
Junior Developer
Junior Developer
 
Posts: 21
Joined: Wed Jan 07, 2009 6:43 pm

Top

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 6 guests