Skip to content

Commit

Permalink
MovieCollectionActivity: use large, multi-line top app bar
Browse files Browse the repository at this point in the history
Scroll effects do not work and break insets, so not using them for now.
  • Loading branch information
UweTrottmann committed Aug 2, 2024
1 parent ff893d3 commit e883024
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.replace
import com.battlelancer.seriesguide.R
import com.battlelancer.seriesguide.databinding.ActivityMovieCollectionBinding
import com.battlelancer.seriesguide.ui.BaseActivity
import com.battlelancer.seriesguide.ui.SinglePaneActivity
import com.battlelancer.seriesguide.util.ThemeUtils
import com.battlelancer.seriesguide.util.commitReorderingAllowed

/**
Expand All @@ -20,7 +21,9 @@ class MovieCollectionActivity : BaseActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val binding = SinglePaneActivity.onCreateFor(this)
val binding = ActivityMovieCollectionBinding.inflate(layoutInflater)
setContentView(binding.root)
ThemeUtils.configureForEdgeToEdge(binding.root)
binding.sgAppBarLayout.sgAppBarLayout.liftOnScrollTargetViewId =
MovieCollectionFragment.liftOnScrollTargetViewId
setupActionBar()
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/res/layout/activity_movie_collection.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent">

<include
android:id="@+id/sgAppBarLayout"
layout="@layout/top_app_bar_medium" />

<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/top_app_bar_elevating.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
android:layout_width="match_parent"
android:layout_height="wrap_content" />

</com.google.android.material.appbar.AppBarLayout>
</com.google.android.material.appbar.AppBarLayout>
35 changes: 35 additions & 0 deletions app/src/main/res/layout/top_app_bar_medium.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>

<!-- This top app bar allows longer titles and elevates if content scrolls behind it,
but stays otherwise in place. -->
<!-- Note: collapsing (setting layout_scrollFlags) breaks insets. -->

<com.google.android.material.appbar.AppBarLayout 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/sgAppBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:liftOnScroll="true">

<!-- Use titleCollapseMode="scale" so CollapsingToolbarLayout
does not disable liftOnScroll of app bar. -->
<com.google.android.material.appbar.CollapsingToolbarLayout
style="?attr/collapsingToolbarLayoutMediumStyle"
android:layout_width="match_parent"
android:layout_height="?attr/collapsingToolbarLayoutMediumSize"
android:theme="@style/ThemeOverlay.SeriesGuide.Toolbar.Surface"
app:maxLines="2"
app:titleCollapseMode="scale">

<androidx.appcompat.widget.Toolbar
android:id="@+id/sgToolbar"
style="@style/Widget.SeriesGuide.Toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:title="App Bar Title That Is Very Long And Will Wrap" />

</com.google.android.material.appbar.CollapsingToolbarLayout>

</com.google.android.material.appbar.AppBarLayout>

0 comments on commit e883024

Please sign in to comment.