Android Studio突然R文件消失的可能原因之一

刚接触android的小伙伴在用Android Studio写代码时,可能会遇到突然一大片代码报红错的情况,本应在app/bulid/generated/source/r 里面的R.java 文件也莫名消失,当尝试Rebuild Project后依然无果时(一般rebuild project就OK了),很可能是(我自己的情况)写了不该有的代码,就好像在写java时,要用某个方法,却因为之前自动补全了错误的包,导致得到了名字相同却不是想要的方法一样,我当时的情况是在Manifest配置文件中添加权限

<uses-permission android:name="android.permission.CALL_PHONE"/>

时,将uses写成user,运行之后R文件消失,一片报红,改后Rebuild Project,R文件终于又回来了  (╯°口°)╯(┴—┴

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
首先,在XML布局文件中定义一个ImageView: ``` <ImageView android:id="@+id/iv_animation" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_check_circle" android:visibility="invisible" android:layout_gravity="center"/> ``` 然后,在Java代码中实现动画效果: ``` // 获取ImageView ImageView ivAnimation = findViewById(R.id.iv_animation); // 定义动画 AnimationSet animationSet = new AnimationSet(true); ScaleAnimation scaleAnimation = new ScaleAnimation(1f, 3f, 1f, 3f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); AlphaAnimation alphaAnimation = new AlphaAnimation(1f, 0f); animationSet.addAnimation(scaleAnimation); animationSet.addAnimation(alphaAnimation); animationSet.setDuration(1000); // 设置动画监听器 animationSet.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { // 动画开始时,显示ImageView ivAnimation.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animation animation) { // 动画结束时,隐藏ImageView,并跳转到下一页 ivAnimation.setVisibility(View.INVISIBLE); Intent intent = new Intent(MainActivity.this, SuccessActivity.class); startActivity(intent); } @Override public void onAnimationRepeat(Animation animation) { } }); // 开始动画 ivAnimation.startAnimation(animationSet); ``` 这个动画效果,是一个放大并逐渐消失的圆圈。通过设置动画监听器,在动画结束时跳转到下一页。具体的实现方式,可以根据自己的需求进行调整。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值