When building a social networking application in Android, there is a need to create and manage user profiles for an effective interaction between different users of your app.
In this article, we will be building a user profile page using the popular LinearLayout in Android. The image below shows the final design screen we will be building. This can be used or modified to meet the requirements of your application profile page when building your next Android application.
Launch the Android Studio IDE and create a new project by selecting the Empty Activity from the list of available template.
In order to implement the circular profile ImageView in the above screen, we will be making use of a library, which is a custom view for circular images in Android. You might want to learn more about the library here.
Open the build.gradle file by navigating to app/build.gradle in your current project directory. Add the below code snippet to the list of dependencies and click on ‘Sync‘ in order to update your project dependencies.
(a) Firstly, open the colors.xml file and add the below code snippet. You will find it under app/src/main/res/values
(b) Secondly, open the strings.xml file under app/src/main/res/value. Edit the file to match up with the code snippet below.
(c) Thirdly, open up the styles.xml file, modify the file with the below code snippet.
Create a new layout XML file under app/src/main/res and name it activity_profile.xml. Copy and paste the below code snippet.
We need to create a new Android activity named ProfileActivity. This should be created under the app/src/main/java . Once you have created the file, copy and paste the code snippet below into it.
Remember to register the newly created Android activity(ProfileActivity) in your AndroidManifest.xml file, in order to prevent the app from crashing.
In the course of our screen layout design, we have made use of some drawable resource files such as the profile image and other icons.
Download the resource files and paste in the drawable folder of your application.
Finally, build the project and run on a physical device or an Android emulator.
For further help, use the comment section below or reach out directly to appdevchannel[at]gmail.com
Related Article: How to Build User Onboarding Screen in Android