In the left side of Android studio, we have different files and they have their own purpose. Here in this article, I will explain every file and their use.
- A brief overview of project files in android studio
- The Best Free Way To Mirror Android Screen To PC
- What is android activity? learn how to create a new activity in the android studio?
- How to use Listview in android studio step by step? android tutorial
- How to use the button in the android studio?
Different files in android studio
Basically, we have two parent directories in the left side of the android studio.
- Gradle script
The directory app contains your all java, kotlin, xml, raw, manifest, layout etc. This directory is super important. In above image app directory is expanded. Here we have following files and directories.
- manifests–> AndroidManifest.xml
- java–> package name –> MainActivity.java
- res–> drawable –> ImageName.png
So these are all important files in the android studio. There is one more directory also i.e. Gradle Scripts. This contains two gradle files. But in this article, we are only focused on app directory files. Now we will see each file and role of these files.
If I opened AndroidManifest.xml you can see xml code. In this we have important tags like<application>, <intent filter>. The application tag contains information like app label (app name), app icon, icon shape, app theme etc. The intent filter tag is used to tell the compiler that it is a Launcher or not. Here Launcher means the activity which will be showing up on starting an app. If we create one more activity than the android studio will automatically add application and intent filter tag. Between two activities we have to tell the compiler that which activity should be LAUNCHER. If we want to have another activity as home screen or launcher then we will make that activity LAUNCHER and another to DEFAULT.
If you want to change the icon of your app then it’s super easy. But keep in mind that android studio only supports png files. Once you have your png image then copy that image and paste in mipmap. Now just change the icon name in android:icon tag.
One more important thing in about manifest file is that for seeking permissions from users, you have to declare that permission in manifest file. For example, if you want to grant internet permissions then paste this code
<uses-permission android:name="android.permission.INTERNET" />
So this is all about manifest and keep in mind that if you created new xml and java manually then you have to add application and intent filter tag manually.
As the name suggests it contains all your java files. Keep in mind that java directory contains 3 sub-directories. If you want to create new java file then always create in same package name in which MainActivity is placed. Now let us explore the MainActivity.java file.
In this java file, our class is inheriting AppCompatActivity and one important override method is onCreate. This onCreate method helps in binding the xml and java file. you can seesetContentView method is taking the path of xml file as an argument. So you don’t need to go in much depth of it. Simply understand it as a method which binds java and xml file. But if you want to read back-end code of any class or method then you can simply press Ctrl and hover the mouse over that method or class.
There is nothing much to say about drawable. If you want to use any image in your application then simply copy and paste it drawable.
You can say xml files as GUI part of your apps. These files decide the look of your app. Here activity_main.xml is default xml file which contains only textView hello world. You can create your own xml file in layout directory or you can create your own directory as well. There are two ways to edit xml. One is design and other is text. If you are familiar with html,css then text version will be better for you. If you don’t know the xml then you can learn it very easily. In design part every thing is drag and drop. For example, if you want to add a button to your app then simply drag the button from palette and drop it in the virtual mobile screen. Now if you check text part of xml, you will find that everything is added automatically. To access properties of any component just select that component from the component tree and at the right side you can access their properties.
This mipmap is similar to drawable but the only difference is it contains different images for different screen sizes. For example, if you use any single image in your app, It may work for your device but when the same application is installed on the different phone of different screen size you will see a lot of difference. So always create different size images and paste them in mipmap.
This directory contains three main files.
In strings, we have all the string values. For example, if we want to add a long list of countries then we should add it in strings.xml. In colors.xml we can add colours to our app. In Style, we can change app theme, colours, app name etc.
So this is a brief overview of the android studio. I hope it would help you to learn android studio better. It may seem to be very complicated but once you become familiar with the android studio, it will become very easy to develop simple android apps. So don’t loose hope and keep it up.
For any query comment below