在Transition Animation之后,EditText提示不可见

时间:2017-05-11 08:23:05

标签: android android-edittext android-animation

我想用过渡动画为EditText设置动画。完成动画后,提示不会显示,但是当我调用edittext.requestLayout或当用户专注于edittext时,会出现提示。 requestLayout 听起来像是一个真正的解决方案?

final EditText text = (EditText) findViewById(R.id.editText);
AutoTransition autoTransition = new AutoTransition();
TransitionSet transitionSet = new TransitionSet();
transitionSet.addTransition(autoTransition);
transitionSet.setDuration(2000);
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) text.getLayoutParams();
params.width = 0;
params.height = 0;
text.setLayoutParams(params);
transitionSet.addListener(new Transition.TransitionListener() {
    @Override
    public void onTransitionStart(@NonNull Transition transition) {

    }

    @Override
    public void onTransitionEnd(@NonNull Transition transition) {
        AutoTransition autoTransition = new AutoTransition();
        TransitionSet transitionSet = new TransitionSet();
        transitionSet.addTransition(autoTransition);
        transitionSet.setDuration(2000);
        LinearLayout.LayoutParams params = (LinearLayout.LayoutParams)  text.getLayoutParams();
        params.width = -2;
        params.height = -2;
        text.setLayoutParams(params);
        TransitionManager.beginDelayedTransition((ViewGroup) text.getParent(), transitionSet);
    }

    @Override
    public void onTransitionCancel(@NonNull Transition transition) {

    }

    @Override
    public void onTransitionPause(@NonNull Transition transition) {

    }

    @Override
    public void onTransitionResume(@NonNull Transition transition) {

    }
});
TransitionManager.beginDelayedTransition((ViewGroup) text.getParent(), transitionSet);
}

1 个答案:

答案 0 :(得分:2)

问题是与支持流量相关的Android错误以及支持27.1.1中的resolved