创建于Android的斜的EditText [英] Creating oblique edittext in android

查看:184
本文介绍了创建于Android的斜的EditText的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要求,以显示我用这个code做这个一个EditText在45度角,以水平axis.So

I have a requirement to show an EditText at 45 degree angled to horizontal axis.So I used this code to do this

EditText editText = (EditText) findViewById(R.id.edit_text);
editText.setText("Hello");
Animation anim = new RotateAnimation(0.0f, -45.0f, 190, 90);
anim.setFillAfter(true);
editText.setAnimation(anim);

这也显示了EditText上按我的要求。但是,当我开始键入它的一些文字问题就出现了。

It also shows the EditText as per my requirement. But problem arises when I started typing some text in it.

正如你可以看到拍摄的画面中,EditText上的一些地方都没有显示文本,并在EditText上的中间部分只显示文本。

As you can see the screen shot, some places of the edittext are not showing the text and at the middle portion of the edittext is only displaying the text.

您好这是在EditText上的左上角只是becase的,我设置使用的setText()

The Hello which is in the left corner of the edittext is just becase of, I set that using setText()

请帮助我如何倾斜创建一个EditText,这样我可以在它适当的类型。

Please help me how to create an edittext obliquely so that I can type properly in it.

推荐答案

经过长期的R&放大器; D,我成功地解决这个,

After a long R&D, I succeed in solving this,

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

}
}

这篇关于创建于Android的斜的EditText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆