简体   繁体   English

Android TranlateAnimation背景不起作用

[英]Android TranlateAnimation background doesn't work

I am usig TranlateAnimation to showing and hiding EditText. 我将TranlateAnimation用于显示和隐藏EditText。 First EditText has visibility gone. 首先EditText的可见性消失了。 After it takes visibility visible and tranlating up. 之后,可见性可见并转化。 When EditText get focus backgroung of all app becomes black. 当EditText获得焦点时,所有应用程序的背景光都会变黑。 When focus of EditText is lost everything becomes good. 当失去EditText的焦点时,一切都会变得很好。 Maybe it's because I use ViewPager which contains all fragrament. 也许是因为我使用了包含所有片段的ViewPager。 What is the problem of this? 这是什么问题? Here is code of animation: 这是动画代码:

private void initAnimationDown() {
    animationDown = new TranslateAnimation(0, 0, 0, height);
    animationDown.setFillAfter(true);
    animationDown.setDuration(500);
    }
private void initAnimationUp() {
    animationUp = new TranslateAnimation(0, 0, height, 0);
    animationUp.setFillAfter(true);
    animationUp.setDuration(500);
    }

@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

    if (isChecked) {
        initAnimationUp();
        perfectEditText.startAnimation(animationUp);
        perfectEditText.setVisibility(View.VISIBLE);

    } else {
        initAnimationDown();
        perfectEditText.startAnimation(animationDown);
        perfectEditText.setVisibility(View.GONE);
    }
}

What if you try to unvalidate the edit text before hidding him and starting animation? 如果在隐藏隐藏文本并开始动画之前尝试取消使其无效,该怎么办?

perfectEditText.setFocusable( false );
perfectEditText.setFocusableInTouchMode( false );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM