Search⌘ K
AI Features

Activity Declaration and Keyboard Support

Explore how to declare the LoginActivity to launch by default using AndroidManifest.xml and address keyboard issues in the login screen. Learn to make layouts scrollable to prevent the keyboard from covering buttons and modify input types to improve user input handling with Kotlin.

Activity declaration

In the previous lesson, we created the activity_login.xml layout. Now it’s time to create the LoginActivity class and bind our layout to this activity by using the setContentView method.

Kotlin
class LoginActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val binding = ActivityLoginBinding.inflate(layoutInflater)
setContentView(binding.root)
}
}

All activities must be registered in AndroidManifest.xml, and because we want LoginActivity to be launched by default when the application starts, it must be declared with the MAIN and LAUNCHER intent filters. So, let’s move the intent filters from the MainActivity to the ...