Skip to content

Commit

Permalink
New logic of backLayout drawing
Browse files Browse the repository at this point in the history
  • Loading branch information
Semper-Viventem committed Feb 10, 2019
1 parent 1e75fc9 commit 57fcac7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class BackdropBehavior : CoordinatorLayout.Behavior<View> {
}

override fun layoutDependsOn(parent: CoordinatorLayout, child: View, dependency: View): Boolean {
if (toolbarId == null || backLayoutId == null) return false
if (toolbarId == null && backLayoutId == null) return false

return when (dependency.id) {
toolbarId -> true
Expand Down Expand Up @@ -171,9 +171,6 @@ class BackdropBehavior : CoordinatorLayout.Behavior<View> {
// TODO (next release): remove this block
if (toolbarId != null) {
backLayout.y = toolbar.y + toolbar.height
frontLayout.layoutParams.height = parent.height - toolbar.height
} else {
frontLayout.layoutParams.height = parent.height - (backLayout.y.toInt() + toolbar.y.toInt() + toolbar.height)
}

drawDropState(frontLayout, toolbar, backLayout, false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ class MainActivity : AppCompatActivity() {

backdropBehavior = foregroundContainer.findBehavior()
with(backdropBehavior) {
attachBackContainer(R.id.backContainer)
attachToolbar(R.id.toolbar)
attachBackLayout(R.id.backContainer)
}
with(toolbar) {
setTitle(R.string.app_name)
Expand Down
20 changes: 10 additions & 10 deletions sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,29 @@
android:background="@color/colorPrimary"
tools:context=".ui.MainActivity">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleTextColor="@color/white"/>

<LinearLayout
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/backContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/small_gap"
android:layout_marginStart="@dimen/small_gap"
android:orientation="vertical">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleTextColor="@color/white"/>

<com.google.android.material.navigation.NavigationView
android:id="@+id/navigationView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/small_gap"
android:paddingEnd="@dimen/small_gap"
android:background="@android:color/transparent"
app:itemBackground="@drawable/bg_menu_item"
app:itemTextColor="@color/white"
app:menu="@menu/main_menu"/>
</LinearLayout>
</com.google.android.material.appbar.AppBarLayout>

<FrameLayout
android:id="@+id/foregroundContainer"
Expand Down

0 comments on commit 57fcac7

Please sign in to comment.