Skip to main content

Points to Remember Before Coding First Application - ABNHive

We need to remember some points before code Android Apps. The points are given below.


  • Package - A package is a namespace. A package is essentially the directory (folder) to which source code belongs. Normally, this is a directory structure that uniquely identifies your application; such as com.helloworld.app. Then you can create packages within your application package that separates your code; such as com.helloworld.app.ui or com.helloworld.app.data. It basically lets you have two classes named Employee if they are in different packages.
  • Class - A class is a blueprint for creating objects in class-based object-oriented programming; you should learn the basics of OOP and understand what an object is, what a class is, what is inheritance, polymorphism, encapsulation before learning anything else about Java.
  • The basic structure for one of the Android project- 
Let's Explore each file
  • AndroidManifest.xml: This is the Android definition file. It contains information about the Android application such as minimum Android version, permission to access Android device capabilities such as in, internet access permission, ability to use phone permission, etc.
Example :

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.abnhive.helloworld"> 
 <uses-sdk android:minSdkVersion="7" />
<application 
    android:versionCode="1"
    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>  
  • java: This folder contains the Java source files with classes and package files. 
  • res: Here we can store resource files such as pictures, XML files for defining layouts, and so forth. Within this folder, there are additional folders such as Drawable, Layout, and Values.
  • build.gradle: This defines your build configuration that applies to all modules. 

Inside res Folder

  • drawable: A Drawable folder contains resource type files like Bitmap (PNG, JPEG), Nine Patch, Vector (XML), Shape, Layers, States, Levels, and Scale.
  • layout: A layout defines the visual structure for a user interface, such as the UI for an Android application. This folder stores Layout files that are written in XML language. Stay tuned for android layouts article.
Example : 

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical" > 
    <TextView android:id="@+id/text"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Hello World" /> 
    <Button android:id="@+id/button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Click Me!" /> 
</LinearLayout> 
  • mipmap: Mipmap folder contains the Image Asset file that can be used in Android Studio application. like Launcher icons, Action bar and tab icons, and Notification icons.
  • colors.xml: contains colour resources of the Android application. Colours are defined in hexadecimal format. 
Example : 

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <color name="colorPrimary">#3ACD7A</color> 
    <color name="colorPrimaryDark">#098B41</color> 
    <color name="colorAccent">#9E3DC1</color> 
</resources> 

  • strings.xml: We can create strings and their names for the application.  The string value is identified by a unique name that can be used in the Android application program
Example : 
<resources> 
    <string name="app_name">ABNHive</string> 
</resources> 
  • styles.xml: contains resources of the theme style in the Android application. We can create our own themes for each segment. 
Example : 
<resources> 
    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item> 
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
        <item name="colorAccent">@color/colorAccent</item> 
    </style> 
</resources> 

- Aswin Bhim Nath

      Comments

      Popular posts from this blog

      Shortcuts in Android Studio for Android Developers - ABNHive

      I hope these shortcuts will definitely help you to increase the productivity level. Search for command: cmd + shift + a ( Windows / Linux : ctrl +  shift + a) You just type: close and you’ll get a proper shortcut/command. Choose from the last copy / pastes : cmd +  shift  + v ( Windows / Linux : Ctrl + Shift + v). By default, there are 5 last copy/paste items. Enable mulmulti cursorature: ctrl + g (alt + j for Windows / Linux ). Open a class: cmd + o ( Windows / Linux : ctrl + n). Open any file: cmd + shift + o ( Windows / Linux : ctrl + shift + n) Open symbol:  cmd + option + o ( Windows / Linux : alt + shift + n). Go to implementation: cmd + option + b ( Windows / Linux : ctrl + alt + b). Go to declaration: cmd + b ( Windows / Linux : ctrl + b).  Go to type declaration: control + shift + b ( Windows / Linux : ctrl + shift + b).  Go to super: cmd + u ( Windows / Linux : ctrl + u).  Move between tabs: cmd + shift + [ (move left) or cmd + shift + ] (move right) ( W

      Android Application Components Activities, Services, Broadcast Recievers, Content Providers - ABNHive

      Application components are the essential building blocks of Android app development.  Each component is an entry point through which the system or a user can enter your app. There are 4 types of components in android Activities Services Broadcast receivers Content providers Let's dive into the deep.  Activities This is a component that represents a single screen with a user interface or simply an entry point for interacting with the user. Example, an email app might have one activity that shows a list of new emails. Activities work together to form a cohesive user experience in the app. For example, clicking a button on the first screen might replace that screen with another screen containing other widgets, a web page, a movie, or text information. Activities are typically created by subclassing (extending) the Android class Activity.  click here   to know more about Activity. Services This runs in the background to perform work for remote processes or

      Linear Layout in Android - ABNHive

      Linear Layout arranges other views either horizontally in a single column or vertically in a single row. It arranges its elements sequentially Attributes android: orientation —Used for arranging the controls in the container in horizontal or vertical order android:layout_width —Used for defining the width of a control android:layout_height —Used for defining the height of a control android:padding —Used for increasing the whitespace between the boundaries of the control and its actual content android:layout_weight —Used for shrinking or expanding the size of the control to consume the extra space relative to the other controls in the container android:gravity —Used for aligning content within a control android:layout_gravity —Used for aligning the control within the container Example <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_widt