If you are not read yet the part-01 blog then first of all you read and implement part-01 visit CLICK HERE. Because this blog linked with part-01

In this part of the blog, we can create a Tab layout and View Pager to show Login Fragment and Signup Fragment for user reliable purposes.

IF YOU SUFFER ANY PROBLEM WITH THIS BLOG THEN YOU MUST VISIT OUR YOUTUBE VIDEO CLICK HERE.

Now, we can create a xml layout named view_bg for background designing.

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

<solid android:color="@color/white" />
<corners
android:topLeftRadius="32dp"
android:topRightRadius="32dp" />

</shape>

Now, we can create a constraint layout to implement TabLayout and ViewPager under constraint layout in MainActivity.

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:background="@drawable/view_bg"
android:elevation="3dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent=".70"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/view"
app:layout_constraintVertical_bias="1">

</androidx.constraintlayout.widget.ConstraintLayout>

Now, we can create a TabLayout under constraint layout for switch between one Fragment to another fragment.

<com.google.android.material.tabs.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0" />

Now, we can create a ViewPager Layout space to show Login Fragment and signup Fragment.

<androidx.viewpager.widget.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent=".7"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tabLayout"
app:layout_constraintVertical_bias="0" />

Now. this part is OVER next part will be available CLICK HERE.


0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *