How to keep transparency through canvas redraw

by isa550 » Fri, 25 Feb 2011 12:58:13 GMT


Sponsored Links
 i,

I need a layout to open with an effect of expanding opening. The
layout grows until it takes the whole screen, but the content is not
scaled.
So I make a layout, override the onDraw, clipRect with a Rect that
grows with a timer.
Until there it works.
But once the layout is fully expanded, it redraws because it contains
a webview with javascript animation. In the "background" of my layout,
I have drawn a slight gray overlay or background using:
canvas.drawArgb(70, 127, 127, 127) method in onDraw().
The problem is, since onDraw() is called again, the background goes
darker, until it is completely gray, it looses its transparency.

I don't manage to avoid this problem.

If I put a background to the layout, it is shown on the whole layout
as soon as it is drawn, so the clipRect does not affect the
background, this is not the behaviour I need...


[code]
private class ExpandedLayout extends RelativeLayout {

private int topRect, bottomRect, leftRect, rightRect;

private int initTopRect, initBottomRect, initLeftRect,
initRightRect;

private Timer viewTimer;

private TimerTask updateMaskTask;


public ExpandedLayout(Context context) {
super(context);
topRect = 0;
bottomRect = screenHeight;
}

public void setBounds(int topInit, int bottomInit, int
leftInit, int
rightInit) {
topRect = topInit;
bottomRect = bottomInit;
leftRect = leftInit;
rightRect = rightInit;

initTopRect= topInit;
initBottomRect = bottomInit;
initLeftRect= leftInit;
initRightRect = rightInit;
}

public void show() {
viewTimer = new Timer();
updateMaskTask = new TimerTask(){
@Override
public void run() {
if (topRect > 0) {
topRect = (topRect-1 < 0) ? 0 :
(topRect-1);
}
if (bottomRect < screenHeight) {
bottomRect = (bottomRect+1 >
screenHeight) ? screenHeight :
(bottomRect+1);
}
if (leftRect > 0) {
leftRect = (leftRect-1 < 0) ? 0
: (leftRect-1);
}
if (rightRect < screenWidth) {
rightRect = (rightRect+1 >
screenWidth) ? screenWidth :
(rightRect+1);
}
postInvalidate();
if ( (topRect == 0) && (bottomRect ==
screenHeight) && (leftRect
== 0) && (rightRect == screenWidth) ) {
updateMaskTask.cancel();
viewTimer.cancel();



Other Threads

1. Finding Ringtone is playing or not?

Is there any api available which can tell me if currently any ring-
tone is playing or not???

-- 

2. display problem in devkit8000

hello all,

I have build the Android eclair kernel with devkit patch. but i am not
able to see  the display on  the board. i am getting the following
error

Power Management for TI
OMAP3.
VFP support v0.3: implementor 41 architecture 3 part 30 variant c rev
1
FIXME: no omap_set_dma_color_mode on
24xx
DMA transaction error with device
0
Console: switching to colour frame buffer device
80x30
omapdss DPI: Could not find exact pixel clock. Requested 23500 kHz,
got 24000 kz
regulator_init_complete: incomplete constraints, leaving VUSB3V1
on
regulator_init_complete: incomplete constraints, leaving VUSB1V8
on
regulator_init_complete: incomplete constraints, leaving VUSB1V5
on
twl4030_rtc twl4030_rtc: setting system clock to 2000-01-01 00:00:00
UTC (94668)
Waiting 1sec before mounting root device.

please suggest me some solution.

-- 
unsubscribe: android-kernel+unsubscr...@googlegroups.com
website: 

3. SCSI support

4. about late resume, when PowerManagerService write on to /sys/power/state to call late resume

5. wifi with WPA2 encryption cannot reconnect to AP after click forget

6. requestLocationUpdates() Parameters question

7. 3GP audio support in Eclair