- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
最佳答案
首先,您需要将 ListView 替换为 WearableRecyclerView。它可以像普通的 ListView 一样使用。但请确保您从 android.support.wear.widget
中导入正确的 . 不要使用 android.support.wearable.view
中的那个.这个应该被划掉,这样你就不会花很长时间来检查你是否使用了正确的那个。如果只有一个 WearableRecyclerView 可供选择,请确保添加 compile 'com.android.support:wear:27.0.0'
到您的 build.gradle (wear) 文件中的依赖项。还要确保您使用的是 <android.support.wear.widget.WearableRecyclerView/>
在您的 activity.xml 中。如果你只想要一个没有任何自定义项目缩放的循环 ListView,只需在你的 onLayoutInflated()
中调用它方法:
your_recyclerview.setEdgeItemsCenteringEnabled(true);
your_recyclerview.setLayoutManager(new WearableLinearLayoutManager(your_activity_context));
如果你想让项目在靠近屏幕中心时放大,事情会变得有点复杂。
首先:将其粘贴到您的 Activity.java 中:
private class CustomScrollingLayoutCallback extends WearableLinearLayoutManager.LayoutCallback {
private static final float MAX_ICON_PROGRESS = 2F;
@Override
public void onLayoutFinished(View child, RecyclerView parent) {
float centerOffset = ((float) child.getHeight() / 2.0f) / (float) parent.getHeight();
float yRelativeToCenterOffset = (child.getY() / parent.getHeight()) + centerOffset;
float progresstoCenter = (float) Math.sin(yRelativeToCenterOffset * Math.PI);
float mProgressToCenter = Math.abs(0.5f - yRelativeToCenterOffset);
mProgressToCenter = Math.min(mProgressToCenter, MAX_ICON_PROGRESS);
child.setScaleX(1 - mProgressToCenter);
child.setScaleY(1 - mProgressToCenter);
child.setX(+(1 - progresstoCenter) * 100);
}
}
然后返回到您的onLayoutInflated() 方法,并输入以下内容:
CustomScrollingLayoutCallback customScrollingLayoutCallback = new CustomScrollingLayoutCallback();
your_recycler_view.setLayoutManager(new WearableLinearLayoutManager(your_context, customScrollingLayoutCallback));
your_recycler_view.setCircularScrollingGestureEnabled(true);
完成。
关于android - 如何在android wear上创建圆形 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38453663/
我一直在 list 中使用以下意图过滤器,一切正常: 这已被弃用,所以我尝试使用: 我可以正常接收消息,但 onPeerConnected 现在永远不会被调用。 public class
我一直在 list 中使用以下意图过滤器,一切正常: 这已被弃用,所以我尝试使用: 我可以正常接收消息,但 onPeerConnected 现在永远不会被调用。 public class
最新的Android Wear更新随附对ChannelApi的支持,可用于向可穿戴设备或手持设备发送文件或从可穿戴设备或手持设备发送文件。问题是我找不到有关如何使用此功能的单个示例。 Android示
我已经根据官方 API 更新了我的 Android Wear 表盘,总体来说进展顺利。然而,我坚持的一件事是从 Android Wear 应用程序中启动配套(手持)配置事件。我只是无法在 AW 应用程
我在 Moto 360 上启用了蓝牙调试并在我的 Nexus4 上启用了 Android Wear 应用程序。 状态显示目标:已断开 从我的电脑转发端口显示状态主机将更改为已连接,但目标状态仍保持断开
Android Wear 生态系统似乎是围绕用户将与之交互然后关闭的快速任务构建的。这对大多数应用程序都很有效,但是对于一个涵盖长时间运行的任务并且在 watch 休眠时不应自动关闭的应用程序呢? 我
我正在 Android 中开发一个应用程序以及 Android Wear 支持。在查看来自 https://developer.android.com/training/building-wearab
我打开了 USB 调试,我显示目标已连接,但我无法连接主机。 当我在我的 PC 上运行以下命令时,我得到指示该命令未完成的输出。 adb forward tcp:4444 localabstract:
据我所知,有两种方法可以为 Android Wear 中的通知设置背景图像。为了记录,两者都以: Bitmap bitmap; Notification.Builder bob = new
我正在编写一个自定义 Android Wear 应用程序,该应用程序应该向连接的主机设备(电话)发送一次性消息。通过 API 挖掘,我发现以下教程应该可以很好地工作:http://developer.
已关闭。此问题需要 debugging details 。目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and the
我正在尝试将文件从我的 Google Wear 发送到我的 Nexus 5。我已经阅读了一些教程并想出了以下代码,但我的手机没有收到文件。 手机: private GoogleApiClient mG
我正在尝试为 Google Wear 设置我的开发环境并遵循了 Google 的 instructions但是一旦我设置了端口转发 (adb -d forward tcp:5601 tcp:5601)
在开发 Android Wear 表盘时,如何检测屏幕是否是圆形且有下巴(又名扁平轮胎带),如 Moto 360?我尝试了 onSurfaceChanged,但宽度和高度是相同的。 我在有下巴的模拟器
我正在为 Android Wear 编写应用程序,我需要在关闭应用程序时实现与 Android Wear 上的 Google map 应用程序类似的行为。 通常,“Swipe-To-Dismiss”手
我正在开发一款适用于 Android Wear 的应用程序,它可以在手机上启动一项 Activity 。一切都很好,但我不想依赖手机上不断运行的后台服务来接收这条消息。理想情况下,我会让 Wearab
我尝试通过启动语音命令启动我的穿戴应用程序。我按照文档 Adding Voice Capabilities .但是,当我尝试通过说(OK Google)“启动我的应用程序”来启动应用程序时,我会收到与
当我使用数字表冠时,我的列表没有滚动 这就是我所做的; public class MainActivity extends Activity { @Override protecte
根据指南: https://developer.android.com/design/wear/patterns.html#Continuing “在必须使用手机的情况下,一旦点击操作按钮并在手机上打
有人可以分享有关使用 Android Wear 使用手腕运动(与触摸屏上的滑动运动相反)进行手势检测的信息吗? API 中有对此的官方支持吗?如果没有,您认为可以通过自定义 ROM 启用此功能吗?考虑
我是一名优秀的程序员,十分优秀!