activity main.xml **** <?xml version="1.0" encoding="utf-8"?> <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:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="LIFE CYCLE" android:textSize="18sp" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintVertical_bias="0.5" app:layout_constraintHorizontal_bias="0.5" tools:ignore="MissingConstraints" /> </androidx.constraintlayout.widget.ConstraintLayout> ******* main activity.kt ***** package com.example.myapplication import android.os.Bundle import android.widget.Toast import androidx.activity.ComponentActivity import androidx.appcompat.app.AppCompatActivity import androidx.core.view.WindowCompat class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) WindowCompat.setDecorFitsSystemWindows(window, false) // Enables edge-to-edge setContentView(R.layout.activity_main) Toast.makeText(applicationContext, "onCreate() called", Toast.LENGTH_SHORT).show() } override fun onStart() { super.onStart() Toast.makeText(applicationContext, "onStart() called", Toast.LENGTH_SHORT).show() } override fun onResume() { super.onResume() Toast.makeText(applicationContext, "onResume() called", Toast.LENGTH_SHORT).show() } override fun onPause() { super.onPause() Toast.makeText(applicationContext, "onPause() called", Toast.LENGTH_SHORT).show() } override fun onStop() { super.onStop() Toast.makeText(applicationContext, "onStop() called", Toast.LENGTH_SHORT).show() } override fun onDestroy() { super.onDestroy() Toast.makeText(applicationContext, "onDestroy() called", Toast.LENGTH_SHORT).show() } } ******
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter