Android Graphics 示例项目教程

随笔1周前发布 飞长视觉
20 0 0

Android Graphics 示例项目教程

graphics-samplesMultiple samples showing the best practices in graphics on Android.项目地址:https://gitcode.com/gh_mirrors/gr/graphics-samples

1. 项目的目录结构及介绍




graphics-samples/


├── app/


│   ├── build/


│   ├── libs/


│   ├── src/


│   │   ├── androidTest/


│   │   ├── main/


│   │   │   ├── java/


│   │   │   │   └── com/


│   │   │   │       └── example/


│   │   │   │           └── graphics/


│   │   │   ├── res/


│   │   │   │   ├── drawable/


│   │   │   │   ├── layout/


│   │   │   │   ├── mipmap/


│   │   │   │   └── values/


│   │   │   └── AndroidManifest.xml


│   │   └── test/


│   └── build.gradle


├── build/


├── gradle/


├── settings.gradle


└── README.md

app/: 包含应用程序的主要代码和资源。
build/: 构建生成的文件。libs/: 第三方库文件。src/: 源代码目录。
androidTest/: 用于Android设备上的测试代码。main/: 主代码目录。
java/: Java源代码。
com/example/graphics/: 具体的应用程序代码。 res/: 资源文件。
drawable/: 可绘制资源。layout/: 布局文件。mipmap/: 图标资源。values/: 字符串和其他值资源。 AndroidManifest.xml: 应用程序的配置文件。 test/: 用于本地单元测试的代码。 build.gradle: 应用程序的Gradle构建文件。 build/: 项目构建生成的文件。gradle/: Gradle配置文件。settings.gradle: 项目的Gradle设置文件。README.md: 项目说明文档。

2. 项目的启动文件介绍

项目的启动文件通常是AndroidManifest.xml中的<activity>标签指定的Activity。例如:




<activity android:name=".MainActivity">


    <intent-filter>


        <action android:name="android.intent.action.MAIN" />


        <category android:name="android.intent.category.LAUNCHER" />


    </intent-filter>


</activity>

在这个示例中,MainActivity是项目的启动Activity。

3. 项目的配置文件介绍

AndroidManifest.xml

AndroidManifest.xml是Android项目的核心配置文件,包含应用程序的基本信息、组件声明、权限声明等。例如:




<manifest xmlns:android="http://schemas.android.com/apk/res/android"


    package="com.example.graphics">


 


    <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=".MainActivity">


            <intent-filter>


                <action android:name="android.intent.action.MAIN" />


                <category android:name="android.intent.category.LAUNCHER" />


            </intent-filter>


        </activity>


    </application>


</manifest>

build.gradle

build.gradle文件用于配置项目的构建过程,包括依赖管理、构建类型、签名配置等。例如:




apply plugin: 'com.android.application'


 


android {


    compileSdkVersion 30


    defaultConfig {


        applicationId "com.example.graphics"


        minSdkVersion 21


        targetSdkVersion 30


        versionCode 1


        versionName "1.0"


        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"


    }


    buildTypes {


        release {


            minifyEnabled false


            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'


        }


    }


}


 


dependencies {

graphics-samplesMultiple samples showing the best practices in graphics on Android.项目地址:https://gitcode.com/gh_mirrors/gr/graphics-samples

© 版权声明

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
暂无评论...