Skip to content

Commit d51f8c9

Browse files
imhappipaulfthomas
authored andcommitted
[Catalog] Add demo for 3 item docked toolbar demo
PiperOrigin-RevId: 734265067
1 parent 4a841f5 commit d51f8c9

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

catalog/java/io/material/catalog/dockedtoolbar/DockedToolbarThreeItemDemoFragment.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import android.view.View;
2525
import android.view.ViewGroup;
2626
import android.widget.Button;
27+
import android.widget.LinearLayout;
2728
import androidx.annotation.LayoutRes;
2829
import androidx.annotation.NonNull;
2930
import androidx.annotation.Nullable;
@@ -45,9 +46,13 @@ public View onCreateDemoView(@NonNull LayoutInflater layoutInflater, @Nullable V
4546
dockedToolbar = view.findViewById(R.id.docked_toolbar);
4647
((AppCompatActivity) requireActivity()).setSupportActionBar(toolbar);
4748

48-
Button leftArrowButton = view.findViewById(R.id.docked_toolbar_left_arrow_button);
49-
Button rightArrowButton = view.findViewById(R.id.docked_toolbar_right_arrow_button);
50-
Button addButton = view.findViewById(R.id.docked_toolbar_add_button);
49+
LinearLayout dockedToolbarChild = view.findViewById(R.id.docked_toolbar_child);
50+
51+
View content = layoutInflater.inflate(getDockedToolbarContent(), dockedToolbarChild, /* attachToRoot= */ true);
52+
53+
Button leftArrowButton = content.findViewById(R.id.docked_toolbar_left_arrow_button);
54+
Button rightArrowButton = content.findViewById(R.id.docked_toolbar_right_arrow_button);
55+
Button addButton = content.findViewById(R.id.docked_toolbar_add_button);
5156
setupSnackbarOnClick(leftArrowButton);
5257
setupSnackbarOnClick(rightArrowButton);
5358
setupSnackbarOnClick(addButton);
@@ -75,4 +80,9 @@ protected int getLayoutResId() {
7580
public boolean shouldShowDefaultDemoActionBar() {
7681
return false;
7782
}
83+
84+
@LayoutRes
85+
protected int getDockedToolbarContent() {
86+
return R.layout.cat_docked_toolbar_small_content;
87+
}
7888
}

catalog/java/io/material/catalog/dockedtoolbar/res/layout/cat_docked_toolbar_small_content.xml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,11 @@
4141
android:layout_weight="1">
4242
<Button
4343
android:id="@+id/docked_toolbar_add_button"
44-
android:layout_width="48dp"
45-
android:layout_height="48dp"
44+
android:layout_width="wrap_content"
45+
android:layout_height="wrap_content"
4646
android:layout_gravity="center"
47-
android:gravity="center"
48-
android:paddingVertical="8dp"
49-
android:paddingHorizontal="8dp"
50-
app:iconSize="24dp"
5147
style="?attr/materialIconButtonFilledStyle"
52-
app:shapeAppearance="?attr/shapeAppearanceCornerMedium"
48+
app:materialSizeOverlay="@style/SizeOverlay.Material3Expressive.Button.IconButton.Small.Square"
5349
android:contentDescription="@string/cat_docked_toolbar_add_button_description"
5450
app:icon="@drawable/ic_add_24px" />
5551
</FrameLayout>

catalog/java/io/material/catalog/dockedtoolbar/res/layout/cat_docked_toolbar_vibrant_fragment.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@
8282
android:layout_width="match_parent"
8383
android:layout_height="match_parent"
8484
android:gravity="center"
85-
android:orientation="horizontal">
86-
<include layout="@layout/cat_docked_toolbar_small_content" />
87-
</LinearLayout>
85+
android:orientation="horizontal"/>
8886
</com.google.android.material.dockedtoolbar.DockedToolbarLayout>
8987

9088
</androidx.constraintlayout.widget.ConstraintLayout>

0 commit comments

Comments
 (0)