Android实现闪屏页效果
作者:luckyliuqs 发布时间:2022-01-17 01:21:47
标签:Android,闪屏页
本文实例为大家分享了Android实现闪屏页效果的具体代码,供大家参考,具体内容如下
1.效果图
2.闪屏页逻辑及布局
2.1 activity_splash.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/splash"
android:scaleType="centerCrop"/>
<Button
android:id="@+id/splash_btn_skip"
android:layout_width="45dp"
android:layout_height="32dp"
android:text="跳过"
android:textStyle="bold"
android:textColor="#fff"
android:background="#30000000"
android:layout_gravity="right"
android:layout_marginTop="30dp"
android:layout_marginRight="30dp"/>
</FrameLayout>
2.2 SplashActivity.java
通过Handler实现
public class SplashActivity extends AppCompatActivity {
//跳过按钮
private Button btnSkip;
private Handler handler = new Handler();
private Runnable runnableToLogin = new Runnable() {
@Override
public void run() {
toLoginActivity();
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
initView();
initEvent();
//延迟4秒
handler.postDelayed(runnableToLogin,4000);
}
//初始化组件
public void initView(){
btnSkip = findViewById(R.id.splash_btn_skip);
}
//监听事件
public void initEvent(){
btnSkip.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//防止LoginActivity被打开两次
handler.removeCallbacks(runnableToLogin);
toLoginActivity();
}
});
}
/**
* 跳转到登录界面
*/
private void toLoginActivity(){
Intent intent = new Intent(this,LoginActivity.class);
startActivity(intent);
finish();
}
@Override
protected void onDestroy() {
super.onDestroy();
//防止内存泄漏
handler.removeCallbacks(runnableToLogin);
}
}
3.设置主题样式
3.1 style.xml中
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme_FullScreen" parent="AppTheme">
<item name="android:windowFullscreen">true</item>
</style>
</resources>
3.2 AndroidManifest.xml中
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myrestaurant">
<uses-permission android:name="android.permission.INTERNET" />
<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/AppTheme">
<activity android:name=".LoginActivity"></activity>
<activity android:name=".SplashActivity"
android:theme="@style/AppTheme_FullScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
来源:https://blog.csdn.net/qq_35507234/article/details/88046858


猜你喜欢
- SchedulingConfigurer实现动态定时,导致ApplicationRunner无效问题描述当通过SchedulingConfi
- 1、简介应客户要求为了是特殊定制的系统更具安全,系统ROM需要使用自己定义的签名,还有一些特殊的场景也会更改系统的签名比如在过cts认证测试
- 本文实例讲述了C#设置输入法的方法。分享给大家供大家参考。具体如下:private void Form1_Load(object sende
- 会报错如下:org.springframework.web.util.NestedServletException: Request pro
- 情景模式的设置大家应当相当熟悉了,但是在Android中如何通过自己的程序进行情景模式的设置呢,情景模
- 介绍备忘录模式(Memento Pattern)是一种行为型设计模式,它允许在不破坏封装性的前提下,捕获并保存一个对象的内部状态,并在之后可
- 使用HttpServletRequest可以防止盗链行为,什么是盗链行为,比如说在一个别的网站上超链接,指向我们的网页中的某个数据,这样从他
- java字段值为null,不返回该字段类上打注解@JsonSerialize(include = JsonSerialize.Inclusi
- 本文项目为大家分享了Java实现 * 面五子棋的具体代码,供大家参考,具体内容如下项目介绍:本次设计是基于知识点Java类和对象以及数组开发的
- 推荐激活教程IntelliJ IDEA 2020最新激活码(亲测有效,可激活至 2089 年)最新idea2021注册码永久激活(激活到21
- 字符串每隔4位加空格今天弄了个银行卡识别功能,回显的时候想要将银行卡号每四位加一个空格,这样核对卡号会方便很多,这里记录一下1.正则表达式实
- 在搜索引擎的开发中,我们需要对Html进行解析。本文介绍C#解析HTML的两种方法。AD: 在搜索引擎的开发中,我们需要对网页的Html内容
- 一、前言:TCP原理简介首先,保证文章完整性,TCP的理论原理还是需要简介一下,略显枯燥๑乛◡乛๑。TCP(传输控制协议,Transmiss
- 1.可能是缓存导致的。解决方法:清除缓存!2.全局编译可能项目依赖别的模块,别的模块修改未进行编译,这时须先对依赖模块进行编译补充知识:ID
- App Crash对于用户来讲是一种最糟糕的体验,它会导致流程中断、app口碑变差、app卸载、用户流失、订单流失等。相关数据显示,当And
- Java的位操作符用来操作整数基本数据类型中的单个“比特”(bit),即代进制位。而我们知道比特就是0和1,那么,位操作就是对这些数据进行基
- int -> String int i=12345;String s="";核心:s=i+""
- 之前我们借助一个SuperSocket实现了一个简易版的服务器, 但是不管是Server还是Session都是使用框架的,本篇博客我们要实现
- 顺序结构按照代码书写的顺序一行一行执行分支结构if 语句基本语法形式:if(布尔表达式){ //条件满足时执行代码
- 需要用到的知识:注解、AOP、ExpiringMap(带有有效期的映射)我们可以自定义注解,把注解添加到我们的接口上。定义一个切面,执行方法