【发布时间】:2018-07-10 22:53:36
【问题描述】:
有没有办法从这个 XML 文件中获取 editText 对象的 XPath 并得到类似于这个 XPath 的结果:
//*[@class='android.widget.FrameLayout' and ./parent::*[@id='key_pos_ime_action']]/*[@class='android.widget.ImageView'])[1]
这是 XML 文件
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android" android:fitsSystemWindows="true" android:layout_width="match_parent" android:layout_height="match_parent">
<LinearLayout android:orientation="vertical" android:paddingLeft="24dp"
android:paddingTop="56dp"
android:paddingRight="24dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView android:layout_gravity="left|right|center_horizontal|fill_horizontal|center|fill|start|end"
android:layout_width="wrap_content" android:layout_height="UNKNOWN_DATA_0x4801" android:layout_marginBottom="24dp" android:src="@drawable/logo" />
<LinearLayout android:focusable="true" android:focusableInTouchMode="true" android:layout_width="UNKNOWN_DATA_0x0" android:layout_height="UNKNOWN_DATA_0x0" />
<android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:layout_marginBottom="8dp">
<EditText android:id="@+id/input_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Email"
android:inputType="text" />
</android.support.design.widget.TextInputLayout> <!-- added by edit -->
</LinearLayout> <!-- added by edit -->
</ScrollView> <!-- added by edit -->
【问题讨论】:
-
我在您的 XML 示例中添加了三个结束标记,以使其格式良好。