如何解决Toast Android 11定制
在Android 11中Toast.setView()
已过时。
我现在想知道是否可以在不使用setView()
的情况下获得类似结果,例如自定义字体,背景颜色,拐角半径等。
在下面可以找到我在setView()
中使用的当前视图。
<com.google.android.material.card.MaterialCardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
android:clickable="false"
android:focusable="false"
app:cardElevation="0dp"
app:cardBackgroundColor="@color/primary_dark"
android:alpha="0.9"
app:cardCornerRadius="@dimen/radius_toast">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/toast_dark_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="@dimen/height_toast"
android:gravity="center"
android:paddingVertical="@dimen/radius_toast"
android:layout_marginHorizontal="@dimen/radius_toast"
android:layout_gravity="center_vertical"
android:fontFamily="@font/playfair_display_regular"
tools:text="Custom toast text"
android:textColor="@color/primary"
android:textSize="@dimen/text_size_regular_14sp" />
</FrameLayout>
</com.google.android.material.card.MaterialCardView>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。