android - Grid View Pager 中的 ScrollView 不适用于 Android Wear

标签 android android-layout android-fragments wear-os

我正在为智能 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/

相关文章:

java - Fragments 和 Activity 中自定义对象是按值传递还是按引用传递?

php - 创建网站的移动快捷方式

java - 以匿名用户 ASMACK XMPP ANDROID 身份登录

android - 如何在android中从下到上动画 View

android - 是否可以将 ConstraintLayout 放在 ScrollView 中?

android - 为全屏 Activity 摆脱不必要的根布局

java - 将 Arraylist 从 fragment 传递到其自己的 Activity

android setText 使我的应用程序崩溃

android - Bottom Sheet 未展开或折叠

android - 如何让 Android 中的 TextView 具有水平滚动和自动滚动?