How to rotate control (checkbox) in 180 or 90 degrees ?
+2
A:
One way is roughly the same as in this question:
public class CheckBox90 extends CheckBox {
public CheckBox90(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onDraw(Canvas canvas) {
canvas.rotate(90,20,20);
super.onDraw(canvas);
}
}
...but that's kind of hacky. Probably better to do it this way. Grab the checkbox images, rotate them in the image editor of your choice, then tell Android to use the rotated versions.
Daniel
2010-06-08 09:46:13
thanks man , great ;)
2010-06-08 14:55:34
How to call in main program (what to type in main.xml) ?
2010-06-08 15:42:18
http://developer.android.com/guide/topics/ui/custom-components.html#modifying
Daniel
2010-06-08 20:21:19
thanks, thanks, thanks... :) I don't have much points to vote for the your post :)
2010-06-08 21:28:03
I'd argue that the hacky way you described is actually better than creating new images - that way, if the whole has a different look and feel and custom checkbox images, the app will use those instead of rotated versions of the standard Android checkboxes. And user346665 - you should be able to mark Daniel's post as the "best answer".
EboMike
2010-06-29 23:20:53
The problem with the hacky way is that I had to play around to figure out which pivot point offset to use - in this case, (20, 20). If the GUI element size changes, those numbers will probably have to change - which is bad. I'm not sure if there's a way to programmatically determine what pivot point to use, as I didn't spend that time researching it, but there may be.
Daniel
2010-07-02 01:14:20