Android登陆界面的简单实现(登陆背景渐变,密码点击隐藏与显示)

        这是一个简单的登录界面,主要有2个效果 1 登陆背景的图片交替渐变,2 密码点击实现隐藏和显示

              1 主要代码:密码点击实现隐藏和显示


  1  public static int flag = 0;//定义按钮多次点击

             2按钮添加事件,点击按钮。if判断是否点击密码显示按钮

  2  showpwd.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        if (flag == 0) {
            //默认设置为密文
            LoginActivity.this.userpwd.setTransformationMethod
                    (PasswordTransformationMethod.getInstance());
            flag = 1;
        } else {//切换成明文
            LoginActivity.this.userpwd.setTransformationMethod
                    (HideReturnsTransformationMethod.getInstance());
            flag = 0;
        }
    }
});
2 这个功能的代码量比较大,而且涉及到背景图片,我这里值贴出代码,如有需要请和我联系,(另外此功能也是在网上看到的,链接丢了,自己可以找找看,还有demo作者看到后,请不要生气,无意冒犯,只是为了新手更好更快的适应开发)

private void initViews() {//初始化背景图片
    mImageView1 = (ImageView) findViewById(R.id.image1);
    mImageView2 = (ImageView) findViewById(R.id.image2);
    mImageView3 = (ImageView) findViewById(R.id.image3);

}

private void startAnimation() {
    ObjectAnimator anim1 = new ObjectAnimator().ofFloat(mImageView1, "alpha", 1f, 0f).setDuration(5000);
    ObjectAnimator anim2 = new ObjectAnimator().ofFloat(mImageView2, "alpha", 0f, 1f).setDuration(5000);
    AnimatorSet set = new AnimatorSet();
    set.playTogether(anim1, anim2);

    ObjectAnimator anim3 = new ObjectAnimator().ofFloat(mImageView2, "alpha", 1f, 0f).setDuration(5000);
    ObjectAnimator anim4 = new ObjectAnimator().ofFloat(mImageView3, "alpha", 0f, 1f).setDuration(5000);
    AnimatorSet set1 = new AnimatorSet();
    set1.playTogether(anim3, anim4);

    ObjectAnimator anim5 = new ObjectAnimator().ofFloat(mImageView3, "alpha", 1f, 0f).setDuration(5000);
    ObjectAnimator anim6 = new ObjectAnimator().ofFloat(mImageView1, "alpha", 0f, 1f).setDuration(5000);
    AnimatorSet set2 = new AnimatorSet();
    set2.playTogether(anim5, anim6);

    AnimatorSet set3 = new AnimatorSet();
    set3.playSequentially(set, set1, set2);
    set3.addListener(new AnimatorListenerAdapter() {

        private boolean mCanceled;

        @Override
        public void onAnimationStart(Animator animation) {
            mCanceled = false;
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            mCanceled = true;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (!mCanceled) {
                animation.start();
            }
        }

    });
    set3.start();
}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值