Fluent UI Android 开源项目教程
fluentui-android项目地址:https://gitcode.com/gh_mirrors/fl/fluentui-android
1. 项目的目录结构及介绍
Fluent UI Android 项目的目录结构遵循典型的 Android 项目结构,以下是主要目录和文件的介绍:
- app/: 包含应用程序的主要代码和资源。
- src/main/java/com/microsoft/fluentui/app/: 包含应用程序的主要 Java 代码。
- src/main/res/: 包含应用程序的资源文件,如布局、字符串、图片等。
- library/: 包含 Fluent UI 库的核心代码。
- src/main/java/com/microsoft/fluentui/library/: 包含 Fluent UI 库的 Java 代码。
- src/main/res/: 包含 Fluent UI 库的资源文件。
- build.gradle: 项目的构建脚本,包含依赖项和构建配置。
- settings.gradle: 包含项目的模块配置。
2. 项目的启动文件介绍
Fluent UI Android 项目的启动文件位于 app/src/main/java/com/microsoft/fluentui/app/MainActivity.java
。这是应用程序的主活动,负责初始化 UI 并处理用户交互。
package com.microsoft.fluentui.app;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
3. 项目的配置文件介绍
Fluent UI Android 项目的配置文件主要包括 build.gradle
和 AndroidManifest.xml
。
build.gradle
build.gradle
文件位于项目根目录和 app/
目录下,分别用于全局配置和应用程序模块配置。
根目录下的 build.gradle:
// 项目级别的构建脚本
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.0'
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
app/ 目录下的 build.gradle:
// 应用程序模块的构建脚本
apply plugin: 'com.android.application'
android {
compileSdkVersion 30
defaultConfig {
applicationId "com.microsoft.fluentui.app"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation 'com.microsoft.fluentui:fluentui_core:0.0.1'
implementation 'com.microsoft.fluentui:fluentui_drawer:0.0.1'
implementation 'com.microsoft.fluentui:fluentui_persona:0.0.1'
}
AndroidManifest.xml
AndroidManifest.xml
文件位于 app/src/main/
目录下,包含应用程序的元数据,如应用程序的组件、权限和配置。
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.microsoft.fluentui.app">
<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>
以上是 Fluent UI Android 开源
fluentui-android项目地址:https://gitcode.com/gh_mirrors/fl/fluentui-android