androidxmlandroid-studio

Floating action bar Align is not working in xml


This is my XML code and design output in the Android studio split mode. You can see a floating action bar at the end bottom of the display. But when I run the application the floating action bar goes to the top end.

The second image is the output when I run the application. But the same code when I run on another Project it's work. But in this project it's not working. But I need it in this project.

This is my XML code and design output in the Android studio split mode. You can see a floating action bar at the end bottom of the display. But when I run the application the floating action bar goes to the top end. The second image is the output when I run the application. But the same code when I run on another Project it's work. But in this project, it's not working. But I need it for this project.

    <?xml version="1.0" encoding="utf-8"?>

<layout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">

    <data>

    </data>

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".sFragments.HomeFragment">


        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/recyclerView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.0"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_bias="0.0" />

        <com.google.android.material.floatingactionbutton.FloatingActionButton
            android:id="@+id/floatingActionButton"
            android:src="@drawable/icon_add"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="16dp"
            android:layout_marginBottom="16dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent" />

    </androidx.constraintlayout.widget.ConstraintLayout>

</layout>

Solution

  • There's a problem with the FrameLayout. I mean which contains the Recycler Item. I gave FrameLayout the wrong height. However, the IDE showed me the correct height. But when I was trying to run, but it was not getting the full height on the devices. So everyone always be aware of this type of silly mistake.