-
manifest 文件
manifest 文件是Android应用程序的配置文件,每一个应用程序都有一个 AndroidManifest.xml 文件。AndroidManifest.xml 是整个Android应用的全局描述文件。
下面是某个AndroidManifest.xml 代码
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.c201801090155.androidprojectstructure" /*声明应用程序包*/>
<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/*配置Intent过滤器*/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
下面是一个 MainActivity 代码
package com.c201801090155.androidprojectstructure;//包名
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;//导入Bundle类
public class MainActivity extends AppCompatActivity {
//Android 中 MainActivity 默认继承 AppCompatActivity类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);//设置当前 Activity 要显示的布局文件
}
}
drawable子目录放图片
layout子目录放布局文件
下面是一个 activity_main.xml 文件
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout //约束布局
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"//指定布局的默认工具
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView//文本组件
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"//要显示的文本
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
mipmap子目录
hdpi | 高分辨率 |
---|---|
mdpi | 中分辨率 |
xhdpi | 超高分辨率 |
xxhdpi | 超超高分辨率 |
xxxhdpi | 超超超高分辨率 |