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

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

<merge xmlns:android="http://schemas.android.com/apk/res/android">
<com.android.gallery3d.ui.GLRootView
android:id="@+id/gl_root_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<View android:id="@+id/gl_root_cover"
android:layout_width="match_parent"
android:layout_height="match_parent"
...

注意到这个layout的根标签为<merge>,因此这个layout是由别的layout整合使用的,再次搜索这个layout,找到了Main.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这个类

Android4.2.2 Gallery2源码分析(2)——发现Gallery.java的更多相关文章

  1. Android4.2.2 Gallery2源码分析(4)——GLCanvas.java

    首先申明,找到这个类是在GLRootView.java中发现的线索.这是一个接口,源码中对该接口作了详细的说明: // // GLCanvas gives a convenient interface ...

  2. Android4.2.2 Gallery2源码分析(5)——GLCanvasImpl.java

    GLCanvasImpl.java是接口GLCanvas的唯一实现类,也就是说二者在功能上完全等同.代码中调用GLCanvas对象函数的地方,等效于调用GLCanvasImpl中的该函数,GLCanv ...

  3. Android 7.0 Gallery图库源码分析1 - 初识Gallery源码

    分析一个项目的源代码时,第一件事就是查看清单文件,找到程序入口,我们从Gallery2源码的清单文件中可以看到GalleryActivity是此应用的启动Activity. <activity ...

  4. jQuery1.6源码分析系列

    原文地址:http://www.cnblogs.com/nuysoft/archive/2011/11/14/2248023.html jQuery源码分析(版本1.6.1) 目录 00 前言开光 0 ...

  5. STL 源码分析《1》---- list 归并排序的 迭代版本, 神奇的 STL list sort

    最近在看 侯捷的 STL源码分析,发现了以下的这个list 排序算法,乍眼看去,实在难以看出它是归并排序. 平常大家写归并排序,通常写的是 递归版本..为了效率的考虑,STL库 给出了如下的 归并排序 ...

  6. ScheduleThreadPoolExecutor源码分析

    ScheduleThreadPoolExecutor源码分析(一) Java中ScheduleThreadPoolExecutor主要用于执行延迟任务或者按照一定的频率执行任务.其中scheduleA ...

  7. JDK1.7源码分析01-Collection

    同步发布:http://www.yuanrengu.com/index.php/20180221.html Java的集合类主要由两个接口派生而出:Collection和Map.Collection是 ...

  8. AbstractQueuedSynchronizer源码分析

    AbstractQueuedSynchronizer源码分析 前提 AQS(java.util.concurrent.locks.AbstractQueuedSynchronizer)是并发编程大师D ...

  9. ArrayList相关方法介绍及源码分析

    目录 ArrayList简介: ArrayList 相关方法介绍 代码表示 相关方法源码分析 ArrayList简介: java.util.ArrayList 是我们最常用的一个类,ArrayList ...

随机推荐

  1. 洛谷P3434 [POI2006]KRA-The Disks [模拟]

    题目传送门 KRA 题目描述 For his birthday present little Johnny has received from his parents a new plaything ...

  2. Python类总结-ClassMethod, StaticMethod

    classmethod-把classmethod装饰的方法变成为类中的方法 作用: 把classmethod装饰的方法变成为类中的方法,这个方法直接可以被类调用,不需要依托任何对象 应用场景: 当这个 ...

  3. 【Python初级】由判定回文数想到的,关于深浅复制,以及字符串反转的问题

    尝试用Python实现可以说是一个很经典的问题,判断回文数. 让我们再来看看回文数是怎么定义的: 回数是指从左向右读和从右向左读都是一样的数,例如1,121,909,666等 解决这个问题的思路,可以 ...

  4. 【BZOJ 4503】4503: 两个串 (FFT)

    4503: 两个串 Time Limit: 20 Sec  Memory Limit: 256 MBSubmit: 497  Solved: 226 Description 兔子们在玩两个串的游戏.给 ...

  5. [APIO2015]巴厘岛的雕塑 --- 贪心 + 枚举

    [APIO2015]巴厘岛的雕塑  题目描述 印尼巴厘岛的公路上有许多的雕塑,我们来关注它的一条主干道. 在这条主干道上一共有\(N\)座雕塑,为方便起见,我们把这些雕塑从 1 到\(N\)连续地进行 ...

  6. [BZOJ4551][TJOI2016&&HEOI2016]树(并查集)

    4551: [Tjoi2016&Heoi2016]树 Time Limit: 20 Sec  Memory Limit: 128 MBSubmit: 1746  Solved: 800[Sub ...

  7. YanghuiTriangle

    Demand 1 用实现循环队列 2 参考PPT用循环队列打印杨辉三角 3 用JDB或IDEA单步跟踪排队情况,画出队列变化图,包含自己的学号信息 4 把代码推送到代码托管平台 5 把完成过程写一篇博 ...

  8. 实用在线小工具 -- Google URL Shortener

          实用在线小工具 -- Google URL Shortener 当你想分享一些你觉得有趣的东西,但是那个链接太长,以至于贴上去一大片.比如在微博上分享一张图片,然后贴上去图片的链接,url ...

  9. hdu 5234 Happy birthday 背包 dp

    Happy birthday Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?p ...

  10. 让Firefox支持offsetX、offsetY

    //计算光标相对于第一个定位的父元素的坐标 function coordinate(e){ var o = window.event || e, coord, coord_X, coord_Y; co ...