新建的AndroidX项目改为Android示例

2021-05-21  本文已影响0人  你的益达233

步骤一:根目录的gradle.properties

android.useAndroidX=false

android.enableJetifier=false

步骤二:app下的build.gradle

plugins {
id 'com.android.application'
}

android {
compileSdkVersion 27
buildToolsVersion "28.0.3"

defaultConfig {
    applicationId "com.cong.tanhuangdemo"
    minSdkVersion 19
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {

api "com.android.support:appcompat-v7:27.1.1"
api "com.android.support.constraint:constraint-layout:1.1.0"
api 'com.android.support:design:27.1.1'
api 'com.android.support:support-v4:27.1.1'

}

注:这里只是个成功的示例,compileSdkVersion和27.1.1有关,也可以换成你需要的

步骤三:修改清单的application的主题

 <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

提供下颜色

<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>

清单AndroidManifest

<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和layout就自己修改即可

上一篇 下一篇

猜你喜欢

热点阅读