【问题标题】:Snackbar for Circular Android Wear Designs圆形 Android Wear 设计的 Snackbar
【发布时间】:2017-01-23 13:37:07
【问题描述】:
Android设计库提供的经典Snackbar在wear项目中工作。
在方形显示中,它们看起来不错,但在圆形显示中则不然。
小吃店的角落被圆形显示器裁剪。
有谁知道解决方法?
我不想用吐司。
看图:
我使用的代码:
Snackbar.make(view, serverMessage, Snackbar.LENGTH_SHORT).show();
谢谢
【问题讨论】:
标签:
android-layout
notifications
wear-os
snackbar
【解决方案1】:
根据Android blog,有几种方法可以做到这一点。这些是:
- 使用 BoxInsertLayout,在使用 Shape-Aware Layout guide 中提到。
Wearable UI 库中包含的BoxInsetLayout 类扩展了 FrameLayout,让您可以定义适用于方形和圆形屏幕的单一布局。此类根据屏幕形状应用所需的窗口插图,并让您轻松对齐屏幕中心或靠近屏幕边缘的视图。
-
WatchViewStub
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/watch_view_stub"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:rectLayout="@layout/rect_activity_main"
应用程序:roundLayout="@layout/round_activity_main"
工具:context="com.android.example.watchviewstub.MainActivity"
工具:deviceIds="wear">