我正在为智能 watch 开发一个应用程序,我有一个包含在 GridViewPager 中的 ScrollView(垂直),它本身包含在一个 FrameLayout 中。
垂直滚动适用于 Sony SmartWatch 3,但不适用于 Moto 360(第一代)。
代码如下:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/shape">
<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">
</android.support.wearable.view.DotsPageIndicator>
</FrameLayout>
在 GridViewPager 内部:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="10dp"
android:background="@color/wl_blue">
<TextView
android:id="@+id/very_long_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/wl_blue"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:paddingLeft="10dp"
android:paddingRight="8dp"
android:fontFamily="sans-serif-medium"
android:textSize="14sp"
android:textColor="@color/white"/>
</RelativeLayout>
</ScrollView>
您知道为什么它不能在 Moto 360 上运行吗?
谢谢你的帮助
最佳答案
我遇到了和你一样的问题。似乎 Moto 360 上的 GridViewPager 处理触摸的方式与其他设备不同。我测试过的其他设备(包括其他圆形 watch )触摸从 GridViewPager 传递到 ScrollView ,但对于 Moto 360,GridViewPager 会消耗触摸本身。
关于android - Grid View Pager 中的 ScrollView 不适用于 Android Wear,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34198129/