In this tutorial we are going to discuss about the basic structure of android app.
When we start an android project in android studio with any template or activity you can say our IDE generates automatically these files
- androidmanifest.xml
- Mainactivity.java
- Content_main.xml
<?xml version="1.0" encoding="utf-8"?>[/su_tab] [su_tab title=”mainactivity.java” disabled=”no” anchor=”” url=”” target=”blank” class=””]
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.passionategeekz.tst">
<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>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
package com.passionategeekz.tst;[/su_tab] [su_tab title=”content_main.xml” disabled=”no” anchor=”” url=”” target=”blank” class=””]
import androidx.appcompat.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);
}
}
<?xml version="1.0" encoding="utf-8"?>[/su_tab][/su_tabs]
<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>
Lets start with Launcher activity
Launcher activity– when app starts which screen to show on app startup is called launcher activity or in other words launcher activity is the startup page When an app is launched from the home screen on an Android device
How to manage/edit Launcher activity (startup screen)
To manage your launcher activity open androidmainfest.xml
and find the below code
<activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter>
The above code contains the launcher activity of an android app
you can modify or play with code create different activity and make them launcher activity and see how they look
ENJOY CODING
No comments:
Post a Comment