(1)Android学习之Android 项目结构

  • Android项目结构

  • 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>
  • java节点

下面是一个 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 要显示的布局文件
    }
}
  • res节点

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超超超高分辨率
value子目录
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值