android edittext 动画,Android-动画发生后,键盘不会显示edittext

我在这里看到了有关键盘未出现的问题/解决方案,但与我的特定问题无关.当您单击一个EditText时,键盘显示正常.但是,当我先为EditText设置动画时,然后当您单击EditText时,键盘将不会显示.

任何想法为什么会发生这种情况?

在“活动”中,我首先为徽标设置动画,然后完成动画设置,然后为EditTexts创建淡入动画.他们完成动画后,我尝试单击它们中的任何一个,但键盘不会出现.

这是我的Activity中的onCreate方法:

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

this.requestWindowFeature(Window.FEATURE_NO_TITLE); //Remove title bar

setContentView(R.layout.login);

final EditText emailField = (EditText) findViewById(R.id.emailField);

final EditText passwordField = (EditText) findViewById(R.id.passwordField);

final TextView logInText = (TextView) findViewById(R.id.logInText);

final Button signupButton = (Button) findViewById(R.id.signupButton);

final Button loginButton = (Button) findViewById(R.id.loginButton);

//animation of logo

ImageView img_animation = (ImageView) findViewById(R.id.encoreLogo);

TranslateAnimation animation = new TranslateAnimation(0.0f, 00f,

0.0f, -400.0f);

animation.setDuration(4000);

animation.setFillAfter(true);

animation.setStartOffset(2000);

img_animation.startAnimation(animation);

animation.setAnimationListener(new AnimationListener() {

@Override

public void onAnimationEnd(Animation animation) {

Animation animFadeIn = AnimationUtils.loadAnimation(getApplicationContext(), android.R.anim.fade_in);

animFadeIn.setDuration(2000);

animFadeIn.setFillAfter(true);

emailField.setAnimation(animFadeIn);

passwordField.setAnimation(animFadeIn);

logInText.setAnimation(animFadeIn);

loginButton.setAnimation(animFadeIn);

signupButton.setAnimation(animFadeIn);

}

@Override

public void onAnimationRepeat(Animation animation) {}

@Override

public void onAnimationStart(Animation animation) {}

});

signupButton.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

Intent myIntent = new Intent(MainActivity.this, SignUpActivity.class);

MainActivity.this.startActivity(myIntent);

}

});

}

这是我对应的login.xml:

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context=".MainActivity" >

android:id="@+id/backroundImage"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentBottom="true"

android:layout_alignParentRight="true"

android:layout_alignParentTop="true"

android:cropToPadding="false"

android:scaleType="centerCrop"

android:src="@drawable/crowdblur1" />

android:id="@+id/encoreLogo"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_centerHorizontal="true"

android:layout_centerVertical="true"

android:adjustViewBounds="true"

android:maxHeight="@dimen/thumbnail_height"

android:maxWidth="@dimen/thumbnail_width"

android:scaleType="centerInside"

android:src="@drawable/hand72" />

android:id="@+id/logInText"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignBottom="@+id/encoreLogo"

android:layout_alignLeft="@+id/passwordField"

android:layout_centerHorizontal="true"

android:layout_centerInParent="true"

android:layout_marginBottom="79dp"

android:paddingLeft="@dimen/left_padding_login_text"

android:text="Login to Encore"

android:textColor="@android:color/white"

android:textSize="@dimen/log_in_text"

android:textStyle="bold"

android:visibility="invisible" />

android:id="@+id/emailField"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignBottom="@+id/encoreLogo"

android:layout_centerHorizontal="true"

android:layout_marginBottom="18dp"

android:background="@drawable/rounded_corners"

android:ems="10"

android:inputType="textEmailAddress"

android:hint="Email"

android:textColor="@android:color/black"

android:textStyle="italic"

android:visibility="invisible" />

android:id="@+id/passwordField"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_below="@+id/encoreLogo"

android:layout_centerHorizontal="true"

android:background="@drawable/rounded_corners"

android:ems="10"

android:inputType="textPassword"

android:hint="Password"

android:textStyle="italic"

android:textColor="@android:color/black"

android:visibility="invisible" />

android:id="@+id/signupButton"

style="?android:attr/buttonStyleSmall"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_below="@+id/loginButton"

android:layout_centerHorizontal="true"

android:layout_marginTop="22dp"

android:background="@android:color/transparent"

android:text="@string/signUp"

android:textColor="#5FC2FF"

android:textSize="@dimen/signupText"

android:textStyle="bold"

android:visibility="invisible" />

android:id="@+id/loginButton"

style="?android:attr/buttonStyleSmall"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_below="@+id/passwordField"

android:layout_centerHorizontal="true"

android:layout_marginTop="14dp"

android:background="@android:color/transparent"

android:text="@string/login"

android:textColor="@android:color/white"

android:textSize="@dimen/signupText"

android:visibility="invisible" />

提前致谢!

解决方法:

如此看来,当您在EditText字段上将可见性设置为INVISIBLE时,它并不想获得焦点.

我通过在动画完成后更改这些字段的可见性来解决此问题:

animFadeIn.setAnimationListener(new AnimationListener() {

@Override

public void onAnimationEnd(Animation animation) {

emailField.setVisibility(View.VISIBLE);

passwordField.setVisibility(View.VISIBLE);

logInText.setVisibility(View.VISIBLE);

loginButton.setVisibility(View.VISIBLE);

signupButton.setVisibility(View.VISIBLE);

}

@Override

public void onAnimationStart(Animation animation) {}

@Override

public void onAnimationRepeat(Animation animation) {}

});

希望这对您有所帮助:)

标签:android-edittext,android-animation,android

来源: https://codeday.me/bug/20191122/2059795.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值