I am having trouble aligning my UI components to top of the constraint layout even though I have constraint them to the start of the page. There is a tiny gap between the ToolBar and where the UI components start. app:layout_constraintTop_toTopOf="parent" -> this line of code always works but I believe the problem could be that I am using a tabbed activity that it might not be compatible.Problem in UI
Any help or guidance would be greatly appreciated.
This is my XML class ->
<ScrollView android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_height="wrap_content"
android:layout_width="match_parent">
<TextView
android:id="@+id/breakfastTV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="9dp"
android:layout_weight="10"
android:text="Breakfast"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/breakfastRecyclerView"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_weight="1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/breakfastTV" />
<TextView
android:id="@+id/lunchTV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="9dp"
android:layout_weight="10"
android:text="Lunch"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/breakfastRecyclerView" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/lunchRecyclerView"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_weight="1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/lunchTV" />
<TextView
android:id="@+id/dinnerTV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="9dp"
android:layout_weight="10"
android:text="Dinner"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/lunchRecyclerView" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/dinnerRecyclerView"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_weight="1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/dinnerTV" />
<TextView
android:id="@+id/otherTV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="9dp"
android:layout_weight="10"
android:text="Other"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/dinnerRecyclerView" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/otherRecyclerView"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_weight="1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/otherTV" />
</androidx.constraintlayout.widget.ConstraintLayout>
CLASS WITH Toolbar ->
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout 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"
android:id="@+id/a"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".Management"
tools:openDrawer="start">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
</androidx.appcompat.widget.Toolbar>
</LinearLayout>
<FrameLayout
android:id="@+id/fragLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/topNavigation"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/topNavigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/windowBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/mgmt_bottom_nav_bar" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/nav_header"
app:menu="@menu/drawer_menu" />
</androidx.drawerlayout.widget.DrawerLayout>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…