Cha*_*har 9 android android-widget android-edittext
我有一个EditText,它通常显示与屏幕X轴平行.我想倾斜地显示它(与横轴成45度左右).是否可以在Android中执行此操作.请指导我一个方向,以便我可以尝试.
在pawelzeiba的答案中得到两个链接之后,我继续解决这个问题,但再次陷入困境,所以我又提出了另一个问题.这是链接.
正如Gunnar Karisson所说,在Android 3.0中引入的View类中有一个setRotation()方法,但我无法使用它,因为我的应用程序应该适用于Android 2.1版本.
所以请帮我解决这个问题.
经过长时间的研发,我通过创建自己的自定义编辑文本成功解决了这个问题,它完美地满足了我的要求。
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);
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
473 次 |
| 最近记录: |