How to make a custom Edittext,so that it will look

2019-07-17 10:11发布

问题:

How to make a custom Edittext,so that it will look like as 45 degree rotated in android and it should editable so that th euser can enter text on that rotated Edittext.I tried it.But I am not getting any solution for it.Please give some idea to do this.

回答1:

You could try overriding EditText onDraw method like so...

@Override
protected void onDraw(Canvas canvas) {
     canvas.save();
     canvas.rotate(45.0f,xpivot,ypivot); //rotate around (x,y) pivot point 
     super.onDraw(canvas);
     canvas.restore();
}

I haven't tested this, but I think it should work.



回答2:

"Custom EditText" means you extend EditText and you override the draw method, drawing the text the way you want it.



回答3:

I find a different way and it is working.

EditText lEditTxt = (EditText)findViewById(R.id.Edit_ID);
        Animation lAnim = new RotateAnimation(0, -45, 250, 50);
        lAnim.setRepeatCount(Animation.INFINITE);
        lEditTxt.startAnimation(lAnim);
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);