Skip to content

Instantly share code, notes, and snippets.

@yusufonderd
Created November 20, 2022 15:08
Show Gist options
  • Save yusufonderd/f37855c44fcd7b0a1027a0fbc4ac725b to your computer and use it in GitHub Desktop.
Save yusufonderd/f37855c44fcd7b0a1027a0fbc4ac725b to your computer and use it in GitHub Desktop.
MainActivity.kt
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:titleTextAppearance="@style/ToolbarTitleTextAppearance" />
<com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:layout_constraintEnd_toEndOf="parent"
ads:layout_constraintStart_toStartOf="parent"
ads:layout_constraintTop_toBottomOf="@+id/toolbar"
tools:visibility="visible" />
<com.google.android.material.divider.MaterialDivider
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
app:dividerColor="@color/gray_200"
app:layout_constraintTop_toBottomOf="@+id/adView">
</com.google.android.material.divider.MaterialDivider>
<com.google.android.material.bottomappbar.BottomAppBar
android:id="@+id/bottomAppBar"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:contentDescription=""
app:contentInsetStart="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/nav_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
app:itemTextAppearanceActive="@style/BottomNavigationViewActiveTextStyle"
app:itemTextAppearanceInactive="@style/BottomNavigationViewTextStyle"
app:labelVisibilityMode="labeled"
app:menu="@menu/bottom_nav_menu" />
</com.google.android.material.bottomappbar.BottomAppBar>
<fragment
android:id="@+id/nav_host_fragment_activity_main"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="0dp"
android:layout_height="0dp"
app:defaultNavHost="true"
app:layout_constraintBottom_toTopOf="@id/bottomAppBar"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/divider"
app:navGraph="@navigation/mobile_navigation" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/app_name"
android:src="@drawable/ic_baseline_add_24"
app:backgroundTint="@color/colorPrimary"
app:layout_anchor="@id/bottomAppBar"
app:layout_anchorGravity="center|top"
app:tint="@color/white" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment