Android 35适配

复制代码
1.App   build.gradle

android {
    namespace 'com.xx.xx'
    compileSdk 35

    defaultConfig {
        applicationId "com.xx.xx"
        minSdk 24
        targetSdk 35
        versionCode 15
        versionName "1.3.2"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
}

 dependencies {
     implementation "org.jetbrains.kotlin:kotlin-stdlib:1.9.24"
     implementation 'androidx.core:core-ktx:1.15.0'
     implementation 'androidx.appcompat:appcompat:1.7.0'
     implementation 'com.google.android.material:material:1.12.0'
     implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
     implementation project(path: ':common')
     testImplementation 'junit:junit:4.13.2'
     androidTestImplementation 'androidx.test.ext:junit:1.1.5'
     androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
     implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.4'
     implementation 'com.hwangjr.rxbus:rxbus:3.0.0'
     implementation 'com.github.tbruyelle:rxpermissions:0.10.2'
     //基础的 OkSocket 功能集成包.您的Socket开发无论是客户端还是Java,都需要此包 (必须集成)
     implementation 'com.tonystark.android:socket:4.2.1'
     implementation 'com.github.ybq:Android-SpinKit:1.4.0'
     implementation 'com.guolindev.permissionx:permissionx:1.7.1'
     /**
      * room
      * 2.4.3版本31
      */
     def room_version = "2.3.0"
     implementation "androidx.room:room-runtime:$room_version"
     // 注解处理器(Kotlin 用 kapt,Java 用 annotationProcessor)
     kapt "androidx.room:room-compiler:$room_version"
     implementation "androidx.room:room-ktx:$room_version"//Coroutines support for Room 协程操作库
     implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2"

     //lifecycle
     implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.7'
     implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.7'
 }
===============

2.gradle.properties增加
android.overridePathCheck=true

3.gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip

4.根目录的build.gradle
   dependencies {
        classpath "com.android.tools.build:gradle:8.6.0"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.24"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }

5 themes.xml

<style name="FullScreen" parent="Theme.AppCompat.Light.NoActionBar">

        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimary</item>
        <item name="colorAccent">@color/colorPrimary</item>

        <item name="windowNoTitle">true</item>

        <item name="android:windowActionModeOverlay">true</item>

        <item name="android:statusBarColor">@android:color/transparent</item>
        <item name="android:navigationBarColor">@android:color/transparent</item>

    </style>

6.BaseActivity

    private fun setImmersiveFullscreen() {

            // 允许内容延伸到系统栏区域
            WindowCompat.setDecorFitsSystemWindows(window, false)

            // Android 10+
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
                window.isStatusBarContrastEnforced = false
                window.isNavigationBarContrastEnforced = false
            }

            // 透明
            window.statusBarColor = Color.TRANSPARENT
            window.navigationBarColor = Color.TRANSPARENT

            val controller = WindowInsetsControllerCompat(
                window,
                window.decorView
            )

            // 隐藏状态栏 + 导航栏
            controller.hide(WindowInsetsCompat.Type.systemBars())

            // 沉浸式
            controller.systemBarsBehavior =
                WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
        }
相关推荐
StarsGreen5 小时前
Android中的seccomp相关信息介绍
android
阿杰m10 小时前
Android源码第二十四章:OTA 与 APEX——重启后换了什么?
android
用户0812680374110 小时前
差点格式化一台 Redmi K80:一次 WebView 翻车的无损救援实录
android·debug·webview
阿杰m10 小时前
Android源码第二十五章:WebView 与 Chromium——网页何时画上屏?
android·android studio
StarsGreen10 小时前
Android中特殊文件的相关说明
android
Digitally13 小时前
6 款优质安卓备份提取工具与备份方案
android
恋猫de小郭16 小时前
Flutter A2UI 1.0 ,原来的 genui 也正式换成了这一套 SDK 了
android·前端·flutter
Wellijohn1 天前
一个 Android 老兵的十年开源路:从 167 star 的滑动控件,到本地优先的 AI Agent
android·人工智能·开源
好的佩奇1 天前
Dart 之元数据与注解
android·flutter·dart
三少爷的鞋1 天前
很多开发者把物理上的分层,当成了架构
android