大佬教程收集整理的这篇文章主要介绍了闪屏 alpha 动画不起作用,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
所以我有一个应用程序,目前有两个活动。一个 SplashScreenActivity 和一个 MainActivity。两个活动之间的转换工作得很好,但问题在于 SplashScreenActivity 本身。其中,有一个 ImageVIEw 应该最初是不可见的,然后淡入。但图像始终不可见。请帮忙。代码如下:
SplashScreenActivity:
package com.degioncloud;
import androIDx.appcompat.app.AppCompatActivity;
import androID.content.Intent;
import androID.os.bundle;
import androID.Widget.ImageVIEw;
public class SplashScreenActivity extends AppCompatActivity {
@OverrIDe
protected voID onCreate(Bundle savedInstanceStatE) {
super.onCreate(savedInstanceStatE);
setContentVIEw(R.layout.activity_splashscreen);
ImageVIEw logo = (ImageVIEw) findVIEwByID(R.ID.iv_logo);
logo.setimageAlpha(0);
logo.animate().Alpha(1f).setDuration(1200).withEndAction(new Runnable() {
@OverrIDe
public voID run() {
Intent i = new Intent(SplashScreenActivity.this,MainActivity.class);
startActivity(i);
overrIDePending@R_502_3721@(androID.R.anim.fade_in,androID.R.anim.fade_out);
finish();
}
});
}
}
SplashScreenActivity 的 XML:
<?xml version="1.0" enCoding="utf-8"?>
<relativeLayout xmlns:androID="http://scheR_849_11845@as.androID.com/apk/res/androID"
xmlns:app="http://scheR_849_11845@as.androID.com/apk/res-auto"
xmlns:tools="http://scheR_849_11845@as.androID.com/tools"
androID:layout_wIDth="match_parent"
androID:layout_height="match_parent"
tools:context=".SplashScreenActivity">
<ImageVIEw
androID:ID="@+ID/iv_logo"
androID:layout_wIDth="200dp"
androID:layout_height="200dp"
androID:src="@mipmap/ic_launcher"
androID:layout_centerInParent="true" />
</relativeLayout>
我的清单文件:
<?xml version="1.0" enCoding="utf-8"?>
<manifest xmlns:androID="http://scheR_849_11845@as.androID.com/apk/res/androID"
package="com.degioncloud">
<application
androID:allowBACkup="true"
androID:icon="@mipmap/ic_launcher"
androID:label="@String/app_name"
androID:rounDicon="@mipmap/ic_launcher_round"
androID:supportsRtl="true"
androID:theme="@style/theme.DegionCloud">
<activity androID:name=".MainActivity" />
<activity androID:name=".SplashScreenActivity"
androID:theme="@style/SplashScreentheme">
<intent-filter>
<action androID:name="androID.intent.action.MAIN" />
<category androID:name="androID.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
@H_452_2@mainActivty 是空的,所以我认为没有必要分享它,但如果您需要任何其他文件,请告诉我,我会发送一份副本。
您需要调用 start()
才能开始动画:
logo.animate().alpha(1f).setDuration(1200).withEndAction(new Runnable() {
@Override
public void run() {
Intent i = new Intent(SplashScreenActivity.this,MainActivity.class);
startActivity(i);
overridePendingTransition(android.R.anim.fade_in,android.R.anim.fade_out);
finish();
}
}).start();
以上是大佬教程为你收集整理的闪屏 alpha 动画不起作用全部内容,希望文章能够帮你解决闪屏 alpha 动画不起作用所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。