Packages工程
1.AndroidManifest.xml
这是整个Android项目的配置文件,在程序中定义的所有四大组件都需要在这个文件里注册。另外还可以在这个文件中给应用程序添加权限声明等。

<?xml version="1.0" encoding="utf-8"?>    <manifest xmlns:android="http://schemas.android.com/apk/res/android"       package="yiwei.com.networktest">        <uses-permission android:name="android.permission.INTERNET"/>                       <application                android:allowBackup="true"            android:icon="@mipmap/ic_launcher"            android:label="@string/app_name"            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>2.layout的activity_main.xml<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:paddingBottom="16dp"    android:paddingLeft="16dp"    android:paddingRight="16dp"    android:paddingTop="16dp"    tools:context=".HelloWorldActivity" >    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="Hello World!" />RelativeLayout>`RelativeLayout:相对布局。xmlns:android定义:android命名空间。xmlns:tools:tools命名空间,用来预览一些布局属性的添加和删除后的效果。android:layout_width:指定了控件的宽度,可选择match_parent,fill_parent,wrap_content,顾名思义,match匹配的意思,wrap包裹的意思,即match_parent表示让当前控件的大小和父布局的大小一样,也就是由父布局来决定当前控件的大小。wrap_content表示让当前控件的大小能够刚好包含住里面的内容,也就是由控件内容决定当前控件的大小。android:layout_height:同上。android:paddingLeft,android:paddingRight,android:paddingTop,android:paddingBottom:站在父view的角度描述问题,它规定它里面的内容必须与这个父view边界的距离。此外还有margin,它是站在自己的角度描述问题,规定自己和其他的view之间的距离,如果同一级只有一个view,那么它的效果基本上就和padding一样了。padding填充; 补白; 边距; [ˈpædɪŋ] TextView:android的控件,用于在布局中显示文字的。                android:text:textview显示的内容,这里就是hello world了。 3.MainActivity.java package com.test.helloworld;import android.os.Bundle;import android.app.Activity;import android.util.Log;import android.view.Menu;public class HelloWorldActivity extends Activity {//HelloWorldActivity 继承Activity,Activity是Android系统的一个活动基类,所有的活动都必须要继承它才能拥有活动的特性    @Override    //onCreate()方法是一个活动被创建时必定要执行的方法    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        //加载布局        setContentView(R.layout.hello_world_layout);        Log.d("HelloWorldActivity", "onCreate execute");    }    @Override    //创建菜单    public boolean onCreateOptionsMenu(Menu menu) {        // Inflate the menu; this adds items to the action bar if it is present.        getMenuInflater().inflate(R.menu.hello_world, menu);        return true;    }}

更多相关文章

  1. ListView的几种使用方法
  2. Android自定义控件——自定义属性
  3. Android(安卓)kotlin 之 Fragment获取控件
  4. Android(安卓)中LayoutInflater的使用
  5. Layout_weight
  6. android HorizontalScrollView的简单使用
  7. Android(安卓)使用自定义Dialog打造ActionSheet菜单
  8. Android之LayoutInflater了解(20190109)
  9. Android(安卓)中文 API (19) ―― TwoLineListItem

随机推荐

  1. Android(安卓)2016年度知名企业公司面试
  2. Android Canvas 画图
  3. android之bundle传递数据--两个activitie
  4. android:省市二级联动下拉框
  5. Android 术语
  6. android的字体相关类Typeface
  7. 个性进度条--------菊花加载----Android
  8. Android AES 文件加密解密
  9. Android 多级菜单的实现
  10. 对Android中Tab的使用总结