The main files in the project:
1) MainActivity.java
This is where the responsive sections of the app are coded
ls app/src/main/java/com/<package_name>/<project_name>
MainActivity.java
package com.aravindsankaran.demoapp;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
2) Layout
This is where the layout of the app page is defined. It is in the XML format. This file can be edited interactively from the IDE. The XML file can be viewed and edited by toggling Design/Text buttons at the bottom
ls app/src/main/res/layout
activity_main.xml
Note that this file is linked with the MainActivity, which containd the response functions for widgets specified in the layout xml
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
</android.support.constraint.ConstraintLayout>
3) AndroidManifest.xml
This file holds the application meta data like app name etc
app/src/main/AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.aravindsankaran.APP_NAME">
<application
android:allowBackup="true"
<!-- the value for this variable is found in mipmap folder under res -->
android:icon="@mipmap/ic_launcher"
<!-- the value for this variable is found in values/strings.xml folder under res -->
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
<!-- the value for this variable is found in values/style.xml folder under res -->
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>
It is recomended to use variables in XML files, so that any changes made are reflected everywhere in the project.
Eg, @string/app_name denotes that a variable named app_name is defined in the XML file res/values/string.xml