How to make a custom Edittext,so that it will look like as 45 degree rotated in android

懵懂的女人 提交于 2019-12-24 02:09:05

问题


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);


来源:https://stackoverflow.com/questions/11105207/how-to-make-a-custom-edittext-so-that-it-will-look-like-as-45-degree-rotated-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!