View Profile Activity in Android Studio – Kotlin & Java

In this article, we will learn how to develop a View Profile Activity in Android Studio in both Kotlin and Java. We will design a View Profile form based on Google Material Design components.

Below we are going to create a simple Activity for viewing Profile. It contains the TextView fields. At the end of this tutorial, the following screen will be designed.

View Profile Activity - Handy Opinion

Create ViewProfile Activity

Now you have to create a new Empty Activity with the name of ViewProfile in your Android Studio.

ViewProfile Activity XML Code

In ViewProfile Activity, we have the ImageView at the top of the screen where the user image is placed, and after that, we have the TextView for the First name and the Last name. Also, we have the TextView for the Email Address and TextView for the Contact number. Copy and Paste the following code in your ViewProfileActivity.xml file.

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".ProfileActivity.ViewProfileActivity">

    <TextView
        android:id="@+id/tv_heading"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="View Profile Information"
        android:textStyle="bold"
        android:textSize="26sp"
        android:textColor="#000"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginTop="24dp"
        />


    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toBottomOf="@id/tv_heading"
        >

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:focusable="true"
            android:focusableInTouchMode="true"
            >


            <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/layout_image"
                android:layout_width="0dp"
                app:layout_constraintWidth_percent="0.7"
                android:layout_height="wrap_content"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                android:layout_marginTop="20dp"
                android:textColorHint="#808080"
                app:layout_constraintTop_toTopOf="parent"
                >

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="165dp"
                    android:src="@drawable/clipart1717870" />
            </com.google.android.material.textfield.TextInputLayout>

            <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/layout_first_name"
                app:helperText="First Name"
                android:layout_width="0dp"
                app:layout_constraintWidth_percent="0.7"
                android:layout_height="wrap_content"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                android:layout_marginTop="14dp"
                android:textColorHint="#808080"
                app:layout_constraintTop_toBottomOf="@+id/layout_image"
                >

                <TextView
                    android:id="@+id/et_first_name"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Handy"
                    android:gravity="center"
                    android:padding="10dp"
                    android:textColor="#000000"
                    android:textColorHint="#808080"
                    android:background="#00000000"
                    android:textSize="15sp"
                    />
            </com.google.android.material.textfield.TextInputLayout>


            <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/layout_last_name"
                android:layout_width="0dp"
                app:helperText="Last Name"
                app:layout_constraintWidth_percent="0.7"
                android:layout_height="wrap_content"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                android:textColorHint="#808080"
                app:layout_constraintTop_toBottomOf="@+id/layout_first_name"
                >

                <TextView
                    android:id="@+id/et_last_name"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:padding="10dp"
                    android:text="Opinion"
                    android:textColor="#000000"
                    android:textColorHint="#808080"
                    android:background="#00000000"
                    android:textSize="15sp"
                    />
            </com.google.android.material.textfield.TextInputLayout>


            <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/layout_email"
                android:layout_width="0dp"
                app:helperText="Email Address"
                app:layout_constraintWidth_percent="0.7"
                android:layout_height="wrap_content"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                android:textColorHint="#808080"
                app:layout_constraintTop_toBottomOf="@+id/layout_last_name"
                >

                <TextView
                    android:id="@+id/et_email"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:padding="10dp"
                    android:textColor="#000000"
                    android:textColorHint="#808080"
                    android:background="#00000000"
                    android:text="handyopinion@gmail.com"
                    android:textSize="15sp"
                    android:inputType="textEmailAddress"
                    />
            </com.google.android.material.textfield.TextInputLayout>


            <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/layout_contact_no"
                android:layout_width="0dp"
                app:helperText="Contact No"
                app:layout_constraintWidth_percent="0.7"
                android:layout_height="wrap_content"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                android:textColorHint="#808080"
                app:layout_constraintTop_toBottomOf="@+id/layout_email"
                >

                <TextView
                    android:id="@+id/et_contact_no"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:padding="10dp"
                    android:textColor="#000000"
                    android:textColorHint="#808080"
                    android:background="#00000000"
                    android:text="0300 1234567"
                    android:textSize="15sp"
                    android:inputType="phone"
                    />
            </com.google.android.material.textfield.TextInputLayout>


        </androidx.constraintlayout.widget.ConstraintLayout>

    </ScrollView>

  </androidx.constraintlayout.widget.ConstraintLayout>

ViewProfile Activity Code

package com.example.handyopinion.ProfileActivity

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.example.handyopinion.R

class ViewProfileActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_view_profile)
    }
}

This code is Android side code related to the User Interface. We are not calling any API on the server to get the data.

That’s it. This is how to develop a ViewProfile Activity in the Android Studio.

If you have any questions or suggestions, feel free to ask in the comments section below. Thanks

Next Articles

1. How to Validate an Email in Android Using Kotlin
2. Reset Password Activity in Android Studio Kotlin and Java
3. Forgot Password Activity in Android Studio Java and Kotlin

Please share this post:
Posts created 41

Ask a Question

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

%d bloggers like this: