Snackbar: Use pill-shaped ripple for button

This commit is contained in:
Patryk Michalik
2021-10-09 15:15:46 +02:00
parent bd56b5ddf3
commit 305569359b
3 changed files with 56 additions and 0 deletions
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="1000dp"/>
</shape>
+51
View File
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 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
http://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.
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/label"
android:layout_height="@dimen/snackbar_content_height"
android:layout_width="0dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:lines="1"
android:ellipsize="end"
android:textSize="@dimen/snackbar_max_text_size"
android:textColor="?android:attr/textColorPrimary"
style="@style/TextTitle" />
<FrameLayout
android:id="@+id/button_wrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:background="@drawable/snackbar_button_wrapper">
<TextView
android:id="@+id/action"
style="@style/TextTitle"
android:layout_width="wrap_content"
android:layout_height="@dimen/snackbar_content_height"
android:background="?android:attr/selectableItemBackground"
android:gravity="center"
android:paddingHorizontal="8dp"
android:textColor="?android:attr/colorAccent"
android:textSize="@dimen/snackbar_max_text_size"
android:textStyle="bold" />
</FrameLayout>
</merge>
@@ -69,6 +69,7 @@ public class Snackbar extends AbstractFloatingView {
int padding = res.getDimensionPixelSize(R.dimen.snackbar_padding);
snackbar.setPadding(padding, padding, padding, padding);
snackbar.setBackgroundResource(R.drawable.round_rect_primary);
snackbar.findViewById(R.id.button_wrapper).setClipToOutline(true);
snackbar.mIsOpen = true;
BaseDragLayer dragLayer = activity.getDragLayer();