【问题标题】:Android UiAutomatorViewer can't detect some ViewsAndroid UiAutomatorViewer 无法检测到某些视图
【发布时间】:2014-11-06 14:59:25
【问题描述】:

我的应用程序遇到 UIAutomatorViewer 问题。如果您查看屏幕截图,突出显示的 View 应该是带有子 TextView 的 FrameLayout,但您看不到。

活动有以下xml:

<!-- A DrawerLayout is intended to be used as the top-level content view using match_parent for both width and height to consume the full space available. -->
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.blahblah.MainActivity">

    <!-- As the main content view, the view below consumes the entire
         space available using match_parent in both dimensions. -->
    <FrameLayout
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />



    <!-- android:layout_gravity="start" tells DrawerLayout to treat
         this as a sliding drawer on the left side for left-to-right
         languages and on the right side for right-to-left languages.
         If you're not building against API 17 or higher, use
         android:layout_gravity="left" instead. -->
    <!-- The drawer is given a fixed width in dp and extends the full height of
         the container. -->
    <fragment
        android:id="@+id/navigation_drawer"
        android:name="com.blahblah.NavigationDrawerFragment"
        android:layout_width="@dimen/navigation_drawer_width"
        android:layout_height="match_parent"
        android:layout_gravity="start" />

</android.support.v4.widget.DrawerLayout>

放置在这个FrameLayout中的片段有如下xml:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent" tools:context="com.blahblah.BlankFragment">

    <!-- TODO: Update blank fragment layout -->
    <TextView android:layout_width="match_parent" android:layout_height="match_parent"
        android:text="@string/hello_blank_fragment" />

</FrameLayout>

有人知道造成这种情况的潜在原因吗?

【问题讨论】:

  • 你有没有弄清楚问题出在哪里?

标签: android navigation-drawer android-uiautomator


【解决方案1】:

也许 id 不见了?尝试为您的 TextView 元素设置 android:id。

【讨论】:

  • 您无需拥有 ID 即可在 uiautomatorviewer 中查看您的视图。
猜你喜欢
  • 2018-02-04
  • 1970-01-01
  • 2020-08-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多