首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

Android4.2.2 Gallery2源码分析(二)——发现Gallery.java

2013-10-31 
Android4.2.2 Gallery2源码分析(2)——发现Gallery.java上文中,main.xml是我直接提出来的,并没有说明是怎么

Android4.2.2 Gallery2源码分析(2)——发现Gallery.java

上文中,main.xml是我直接提出来的,并没有说明是怎么找到它的,现在说明发现它的理由:

一般我们分析界面布局会用到hierarchyviewer这个工具,从工具中,我们对应到视图,最主要的视图id我们找到了"gl_root_view",这一点在上一节中有说明。在Source insight中搜索这个id,我们找到了layout/Gl_root_group.xml:

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"        android:id="@+id/gallery_root"        android:orientation="vertical"        android:layout_width="match_parent"        android:layout_height="match_parent">    <include layout="@layout/gl_root_group"/>    <FrameLayout android:id="@+id/header"            android:visibility="gone"            android:layout_alignParentTop="true"            android:layout_width="match_parent"            android:layout_height="wrap_content"/>    <FrameLayout android:id="@+id/footer"            android:visibility="gone"            android:layout_alignParentBottom="true"            android:layout_alignParentLeft="true"            android:layout_alignParentRight="true"            android:layout_width="match_parent"            android:layout_height="wrap_content"/></RelativeLayout>

综合上节中用hierarchyviewer看到的界面布局,因此这个Main.xml就是Gallery的主视图入口,在Gallery工程中搜索调用这个Main.xml的Activity。找到了Gallery.java这个类,从名字上应该有所发觉,这个类有点像我们以往所见的ActivityMain.java。因此Gallery.java是这个布局所对应的activity。

我们先抛开GLRootView.java这个视图,先从activity入手分析一下Gallery.java这个类

热点排行