Android – Move Views Out of The Way with Kotlin
We have seen many views within our android application that change their position with respect to other views to adjust them within the screen. We can get to see when we are displaying a snack bar along with the Floating action button. When the SnackBar is displayed the floating action button is slightly moved upwards. For implementing this behavior for the custom views within our application we can use the Coordinator layout within our application. In this article, we will take a look at How to Move Views Out of the Way with dodgeInsetEdges within our Android application using Kotlin.
Note: If you are looking to implement dodgeInsetEdges within your android application using Java. Check out the following article: How to Move Views Out of the Way With dodgeInsetEdges in Android using Java
Step by Step Implementation
Step 1: Create a New Project in Android Studio
To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. Note that select Kotlin as the programming language.
Step 2: Working with the activity_main.xml file
Navigate to the app > res > layout > activity_main.xml and add the below code to that file. Below is the code for the activity_main.xml file.
Step 3: Working with MainActivity.kt file
Go to the MainActivity.kt file and refer to the following code. Below is the code for the MainActivity.kt file. Comments are added inside the code to understand the code in more detail.
Now run your application to see the output of it.
Please Login to comment...