wear-os - GridViewPager的页面位置

标签 wear-os

我想添加小页面位置指示器(屏幕底部的小圆圈),例如用于GridViewPager的Android Wear中用于通知的指示器。

做这个的最好方式是什么?对我来说,一个小问题是我在垂直方向上使用了GridViewPager,但我认为这可以弄清楚。

我是否必须完全手动执行此操作,或者是否有任何控件会有所帮助?

编辑:
添加了我需要清楚的图像。

最佳答案

可穿戴设备的新版本具有此功能。

您所要做的就是将您对build.gradle的依赖关系更新为:

 compile "com.google.android.support:wearable:1.1.+"

并执行以下操作:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.wearable.view.GridViewPager
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:keepScreenOn="true" />

<android.support.wearable.view.DotsPageIndicator
    android:id="@+id/page_indicator"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal|bottom" />

</FrameLayout>

并在您的 Activity 中这样声明:
 DotsPageIndicator dotsIndicator = (DotsPageIndicator)findViewById(R.id.page_indicator);

 dotsIndicator.setPager(mViewPager);

关于wear-os - GridViewPager的页面位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24883134/

相关文章:

android - 可穿戴设备支持库 1.1 中缺少 WearableListView.Item

android - 如何将 Intent 从我的 Android 手机发送到配对的 Google Glass

android - 如何自动将APK从手机推送到Wear?

android - 从安卓 watch 发送数据到智能手机

安卓磨损 : Starting a service on Handheld

android - 如何在android wear中加载URL图片?

wear-os - 在CanvasWatchFaceService.Engine onDraw中, Canvas 的宽度和高度可以与边界提供的不同吗?

java - Android HTTP 请求在模拟器中工作但不在磨损设备上

java - 在 Android 中动画旋转图像

android - 延迟确认按钮动画