Hi all,
I have created rectangle bars using shapedrawable objects in ondraw
method and canvas. I filled each horizontal bar with a color.
Following is my class, which i wrote to create those graphs.

public class RectangleView extends View{

private Paint mPaint;
private ShapeDrawable[] mDrawables1,mDrawables2;


public RectangleView(Context context) {
super(context);
setFocusable(true);
setBackgroundColor(0xFFFFFFFF);

mDrawables1 = new ShapeDrawable[1];
mDrawables2 = new ShapeDrawable[1];

mDrawables1[0].getPaint().setColor(0xFF347235);
mDrawables2[0].getPaint().setColor(0xFF348017);

}

@Override protected void onDraw(Canvas canvas) {

for (Drawable dr : mDrawables1) {
int x1 = 80;
int y1 = 45;
int width1 = 150;
int height1 = 20;
dr.setBounds(x1, y1, x1 + width1, y1 + height1);
dr.draw(canvas);
//((GradientDrawable) dr).setGradientCenter(20.0f, 150.0f);
y1 += height1 + 5;
}

for (Drawable dr : mDrawables2) {
int x1 = 80;
int y1 = 15;
int width1 = 150;
int height1 = 20;
dr.setBounds(x1, y1, x1 + width1, y1 + height1);
dr.draw(canvas);
y1 += height1 + 5;
}
}
}

I can use the images created in photoshop in my app. But I dont need
any static bars, rather than dynamic rectangles.
Here what i am doing is, i have used those rectangle bars to create a
bar graph for my application. That means whenever user changes his
status, the size of the bars should be changed dynamically. Because of
that reason i have used shapedrawable object and ondraw(canvas). I am
successful to creating bar graph and all without using any xml layout.
I just need to add those gradient effect to my horizontal rectangles.
If any one faced this experience please give some idea to reach my
requirement. any response would be appreciated.


thanks in advance.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to