美文网首页
TV开屏页

TV开屏页

作者: BeRicher | 来源:发表于2022-04-08 00:03 被阅读0次

目前安卓的开屏已经不推荐自己创建SplashActivity了,而是使用系统自带的开屏。

安卓12以后自带这个依赖,安卓12以前我们需要引入适配依赖:

在app模块下:

implementation 'androidx.core:core-splashscreen:1.0.0-beta02'

在AndroidManifest.xml中,将MainActivity设置为主入口:

 <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
  </intent-filter>

在AndroidManifest.xml中,修改application节点,增加

    <application
        android:theme="@style/SplashTheme">

在values目录下的themes.xml中,增加

    <style name="MainTheme" parent="@style/Theme.Leanback" />
    <style name="SplashTheme" parent="Theme.SplashScreen">
        <item name="windowSplashScreenBackground">#CCCCCC</item>
        <item name="windowSplashScreenAnimatedIcon">@mipmap/logo</item>
        <item name="postSplashScreenTheme">@style/MainTheme</item>
    </style>

新建values-v31目录及themes.xml文件,增加:

<resources>
    <style name="SplashTheme" parent="Theme.SplashScreen">
        <item name="android:windowSplashScreenBackground">#CCCCCC</item>
        <item name="android:windowSplashScreenAnimatedIcon">@mipmap/logo</item>
    </style>
</resources>

MainActivity中,onCreate方法改为:

 override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        installSplashScreen()
        setContentView(R.layout.activity_main)
        preInitApp();
    }

    //进入主页面之前需要预加载的工作
    private fun preInitApp(){
        val contentView: View = findViewById(android.R.id.content)
        contentView.viewTreeObserver.addOnPreDrawListener {
            //todo 处理应用程序的初始化工作
            Thread.sleep(3000)
            false
        }
    }

相关文章

  • TV开屏页

    目前安卓的开屏已经不推荐自己创建SplashActivity了,而是使用系统自带的开屏。 安卓12以后自带这个依赖...

  • android开屏页的实现--图片和视屏

    图片引导页结合咕咚,视屏开屏页引进蚂蜂窝的案例。 一、如何实现android开屏页,滑动小圆点带动图片切换。 大概...

  • 总结

    开屏页:引导用户和停留几秒是为了做初始化工作 为什么在开屏页或者引导页把用户信息获取出来?因为进入主页的时候就要显...

  • 针对Android Tv的自定义RecyclerView

    前言:Android TV Launcher页在RecyclerView出来之前大家用GridView去实现。TV...

  • 快手SDK接入开屏页广告

    //快手开屏页广告 public void showKuaishouAd() {KsScene scene =ne...

  • app开屏页广告的取舍 2020-03-11

    有些app开屏页是没有广告的,例如:微信、央视频等。但大多数app开屏页都有3-5秒都广告,例如:知乎、简书等。 ...

  • iOS开屏页设计演变

    一. 开屏页的对与错 目前大多数APP在启动的时候都会使用开屏页,比如网易新闻,微博,头条等。 实际上,并不是所有...

  • 开屏页 launch screen

    概述:说到开屏页面,印象最深的应该是微信的小人,也引起了大家对这幅开屏页面的大量分析讨论。相比国内大部分APP的l...

  • RecyclerView Adapter 的问题

    前言 因为之前一直写 TV 相关的业务,而 TV 业务多半为列表页展示必然使用 RecyclerView,当然我们...

  • IOS-开屏广告页

    思路在一个新的UIWindow的最上层添加一个控制器 用SDWebImage异步加载从接口获取的图片,把图片平铺在...

网友评论

      本文标题:TV开屏页

      本文链接:https://www.haomeiwen.com/subject/ejeesrtx.html