android入门小结一

一 Android入门基础:从这里开始

gradle介绍:

Android Studio使用Gradle 编译运行Android工程. 工程的每个模块以及整个工程都有一个build.gradle文件。通常你只需要关注模块的build.gradle文件,该文件存放编译依赖设置,包括defaultConfig设置:

  • compiledSdkVersion 是我们的应用将要编译的目标Android版本,此处默认为你的SDK已安装的最新Android版本(如果你没有安装一个可用Android版本,就要先用SDK Manager来完成安装),我们仍然可以使用较老的版本编译项目,但把该值设为最新版本,可以使用Android的最新特性,同时可以在最新的设备上优化应用来提高用户体验。
  • applicationId 创建新项目时指定的包名。
  • minSdkVersion 创建项目时指定的最低SDK版本,是新建应用支持的最低SDK版本。
  • targetSdkVersion 表示你测试过你的应用支持的最高Android版本(同样用API level表示).当Android发布最新版本后,我们应该在最新版本的Android测试自己的应用同时更新target sdk到Android最新版本,以便充分利用Android新版本的特性。更多知识,请阅读Supporting Different Platform Versions
    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 28
        defaultConfig {
            applicationId "com.example.panzq.myapplication"
            minSdkVersion 23
            targetSdkVersion 28
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    
    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'com.android.support:appcompat-v7:28.+'
        implementation 'com.android.support.constraint:constraint-layout:1.0.2'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.1'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    }

    ####待补充》》》

添加ActionBar

猜你喜欢

转载自www.cnblogs.com/qiangge-python/p/9644913.html