Add GM chipgroup style. Configure GM Catalog's chip group example to meet Android's recommended min touch target.

PiperOrigin-RevId: 210903536
This commit is contained in:
connieshi 2018-08-30 10:00:31 -04:00 committed by ymarian
parent 1335815927
commit 52ff5e1eb3
5 changed files with 39 additions and 6 deletions

View File

@ -38,9 +38,7 @@ public class ChipGroupDemoFragment extends DemoFragment {
@Override
public View onCreateDemoView(
LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) {
View view =
layoutInflater.inflate(
R.layout.cat_chip_group_fragment, viewGroup, false /* attachToRoot */);
View view = layoutInflater.inflate(getChipGroupContent(), viewGroup, false /* attachToRoot */);
ViewGroup content = view.findViewById(R.id.content);
@ -62,6 +60,11 @@ public class ChipGroupDemoFragment extends DemoFragment {
return view;
}
@LayoutRes
protected int getChipGroupContent() {
return R.layout.cat_chip_group_fragment;
}
@LayoutRes
protected int getChipGroupItem(boolean singleSelection) {
return singleSelection

View File

@ -39,8 +39,11 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical">
<LinearLayout
android:id="@id/chip_group_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:gravity="center_horizontal"
android:orientation="vertical">
@ -53,7 +56,8 @@
android:id="@+id/reflow_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"/>
android:layout_margin="16dp"
app:chipSpacing="8dp"/>
<!-- Scrolling chip group. -->
<TextView
@ -68,6 +72,7 @@
android:id="@+id/scroll_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:chipSpacing="8dp"
app:singleLine="true"/>
</HorizontalScrollView>
</LinearLayout>

View File

@ -17,6 +17,8 @@
<com.google.android.material.chip.Chip
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
style="@style/Widget.MaterialComponents.Chip.Choice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
android:layout_height="wrap_content"
app:chipTouchTargetDelegate="@id/chip_group_parent"/>

View File

@ -17,6 +17,8 @@
<com.google.android.material.chip.Chip
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
style="@style/Widget.MaterialComponents.Chip.Filter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
android:layout_height="wrap_content"
app:chipTouchTargetDelegate="@id/chip_group_parent"/>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2018 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<!-- Used by app:chipTouchTargetDelegate to extend a touch boundary in a chip set. -->
<item type="id" name="chip_group_parent"/>
</resources>