【发布时间】:2015-05-27 08:58:04
【问题描述】:
我正在使用XmlPullParser 解析布局文件,我需要计算内部标签才能识别子视图。我找到了计算每个标签的属性的方法,但找不到如何准确计算标签。
我有这样的代码:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#0d3fff"
android:text="New Button 1"
android:layout_marginRight="10dp"
android:id="@+id/btnDef1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnDef2"/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/tv1"/>
</LinearLayout>
有人知道如何计算标签LinearLayout 的孩子吗?
提前致谢。
【问题讨论】:
标签: android xml xml-parsing xmlpullparser android-xmlpullparser