Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Showing edittext obliquely in android

I have an EditText, which generally shows parallel to the screen X-axis. I want to show it obliquely (around 45 degree to horizontal axis). Is it possible to do this in Android. Please guide me in a direction so that I can try for it.

After getting the two links in the answer by pawelzeiba, I proceed a little bit in solving this, but stuck again so I put another question on this. here is the link.

As Gunnar Karisson said, there is a setRotation() method in View class introduced in Android 3.0, but I cannot use it as my application should work fro Android 2.1 version.

So please help me to solve this.

like image 680
Chandra Sekhar Avatar asked Jun 14 '12 12:06

Chandra Sekhar


2 Answers

EditText is an indirect subclass of View which has a rotation field you can set with setRotation(float):

myEditText.setRotation(45.0f).

like image 81
onosendai Avatar answered Nov 10 '22 14:11

onosendai


After a long R & D, I succeed to solve this by creating my own custom edittext, which works perfectly as per my requirement.

public class CustomEditText extends EditText {

private Animation rotateAnim;
public CustomEditText(Context context) {
        super(context);
}

public CustomEditText(Context context, AttributeSet attrs){
    super(context, attrs);
}

private void createAnim(Canvas canvas) {
        rotateAnim = new RotateAnimation(0, -45, 250, 50);
        rotateAnim.setRepeatCount(Animation.INFINITE);
        startAnimation(rotateAnim);
}

@Override
protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        // creates the animation the first time
        if (rotateAnim == null) {
                createAnim(canvas);
        }

}
}
like image 36
Chandra Sekhar Avatar answered Nov 10 '22 14:11

Chandra Sekhar