如何使Edittext在点击后变得更大

时间:2017-07-25 07:02:23

标签: java android

我希望在开始编写后让我的编辑文字更大。 正如我在图像中所示。Image 那我该怎么办?!任何人都有任何想法!?

1 个答案:

答案 0 :(得分:1)

您需要检查焦点在editText并设置AnimatioValue

 edt.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View arg0, boolean hasfocus) {
                if (hasfocus) {
                    Log.e("TAG", "edt focused");
                    //ValueAnimator total
                    ValueAnimator valueAnimator = ValueAnimator.ofFloat(1f, 1.5f);
                    valueAnimator.setDuration(325);
                    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                        public void onAnimationUpdate(ValueAnimator animation) {
                            float value = (Float) animation.getAnimatedValue();
                            edt.setScaleX(value);
                            edt.setScaleY(value);
                            edt.requestLayout();
                        }
                    });
                    valueAnimator.start();
                } else {
                    Log.e("TAG", "edt not focused");
                    //animation inverse
                }
            }
 });