Skip to content

Commit e51767d

Browse files
manabu-nakamurahunterstich
authored andcommitted
[Catalog][FloatingToolbar] Fixed top app bar container fill
Resolves #4451 GIT_ORIGIN_REV_ID=f709d2c7743dd76f513414a02ad54da86cf51cb4 PiperOrigin-RevId: 705307074
1 parent 2a0dda8 commit e51767d

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

catalog/java/io/material/catalog/floatingtoolbar/FloatingToolbarMainDemoFragment.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import android.graphics.Paint;
2222
import android.graphics.Typeface;
2323
import android.os.Bundle;
24+
import androidx.appcompat.app.AppCompatActivity;
25+
import androidx.appcompat.widget.Toolbar;
2426
import android.view.LayoutInflater;
2527
import android.view.View;
2628
import android.view.ViewGroup;
@@ -51,6 +53,9 @@ public View onCreateDemoView(
5153
View view = layoutInflater.inflate(getLayoutResId(), viewGroup, /* attachToRoot= */ false);
5254
TextView bodyText = view.findViewById(R.id.body_text);
5355

56+
Toolbar toolbar = view.findViewById(R.id.toolbar);
57+
((AppCompatActivity) requireActivity()).setSupportActionBar(toolbar);
58+
5459
// Initialize group of floating toolbars.
5560
List<FloatingToolbarLayout> floatingToolbars =
5661
DemoUtils.findViewsWithType(view, FloatingToolbarLayout.class);
@@ -186,4 +191,9 @@ private int getRandomColor() {
186191
protected int getLayoutResId() {
187192
return R.layout.cat_floating_toolbar_fragment;
188193
}
194+
195+
@Override
196+
public boolean shouldShowDefaultDemoActionBar() {
197+
return false;
198+
}
189199
}

catalog/java/io/material/catalog/floatingtoolbar/res/layout/cat_floating_toolbar_fragment.xml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,24 @@
1717
xmlns:android="http://schemas.android.com/apk/res/android"
1818
xmlns:app="http://schemas.android.com/apk/res-auto"
1919
android:layout_width="match_parent"
20-
android:layout_height="match_parent"
21-
android:padding="8dp">
20+
android:layout_height="match_parent">
21+
22+
<com.google.android.material.appbar.AppBarLayout
23+
android:layout_width="match_parent"
24+
android:layout_height="wrap_content"
25+
android:fitsSystemWindows="true">
26+
<androidx.appcompat.widget.Toolbar
27+
style="?attr/catalogToolbarWithCloseButtonStyle"
28+
android:id="@+id/toolbar"
29+
android:layout_width="match_parent"
30+
android:layout_height="wrap_content"
31+
app:title="@string/cat_floating_toolbar_title"/>
32+
</com.google.android.material.appbar.AppBarLayout>
2233

2334
<androidx.core.widget.NestedScrollView
2435
android:layout_width="match_parent"
25-
android:layout_height="match_parent">
36+
android:layout_height="match_parent"
37+
app:layout_behavior="@string/appbar_scrolling_view_behavior">
2638
<LinearLayout
2739
android:id="@+id/body_container"
2840
android:layout_width="match_parent"

0 commit comments

Comments
 (0)