My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

package com.beanie.examples.invertedbutton;

import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.view.Gravity;
import android.widget.Button;

public class InvertedButton extends Button {

public InvertedButton(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
setWillNotDraw(false);
setGravity(Gravity.CENTER);
}

public InvertedButton(Context context, AttributeSet attrs) {
super(context, attrs);
setWillNotDraw(false);
setGravity(Gravity.CENTER);
}

public InvertedButton(Context context) {
super(context);
setWillNotDraw(false);
setGravity(Gravity.CENTER);
}

@Override
protected void onDraw(Canvas canvas) {
int left = getPaddingLeft();
int top = getPaddingTop();
int right = getPaddingRight();
int bottom = getPaddingBottom();
int width = getWidth() - left - right;
int height = getHeight() - top - bottom;

int saveCount = canvas.getSaveCount();
canvas.translate(left + width / 2, top + height / 2);
canvas.rotate(-180);
canvas.translate((-width / 2)-left, (-height / 2)-top);
canvas.restoreToCount(saveCount);

super.onDraw(canvas);

}

}

Change log

r36 by coomar.101 on Apr 3, 2011   Diff
Initial commit
Go to: 
Project members, sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 1364 bytes, 49 lines
Powered by Google Project Hosting