上文中,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. HDU5883 The Best Path(欧拉回路 | 通路下求XOR的最大值)

    本文链接:http://www.cnblogs.com/Ash-ly/p/5932748.html 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=588 ...

  2. powershell 性能测试小脚本

    powershell 性能测试: 转载请注明: 仰望高端玩家的小清新 http://www.cnblogs.com/luruiyuan/ 1. 将待测试的脚本封装在代码块中 2. 使用  Get-Ch ...

  3. 路径方案数 [SPFA,拓扑排序]

    路径方案数 [题目描述] 给一张无向图,n 个点和 m 条边,cyb 在 1 号点,他要去 2 号点, cyb 可以从 a 走到 b,当且仅当 a 到 2 的最短路,比 b 到 2 的最短路长. 求 ...

  4. disconf-client-for-java

    一.disconf客户端部署 disconf目前仅支持java客户端,下文针对java客户端安装作为整理,记录下安装部署的步骤 1.环境依赖 首先需要安装java环境及maven环境,不再过多介绍 2 ...

  5. struts2的action编写

    例 HelloWorld.jsp <% @ page contentType = "text/html; charset=UTF-8 " %> <% @ tagl ...

  6. JZYZOJ1330 土地购买 dp 斜率优化

    不用long long的话只能ac一半的点而且完全查不出来错...放弃cin保平安..   x[i],y[i]分别为第i块土地的长和宽,输入后需要排序然后去掉冗余数据,最后得到的x[i]递增y[i]递 ...

  7. [HAOI2015]数组游戏

    题目大意: 有一排n个格子,每个格子上都有一个白子或黑子,在上面进行游戏,规则如下: 选择一个含白子的格子x,并选择一个数k,翻转x,2x,...,kx格子上的子. 不能操作者负. 思路: 将“某个格 ...

  8. Android ConstraintLayout约束控件链接整理

    Android新特性介绍,ConstraintLayout完全解析 探索Android ConstraintLayout布局 了解使用Android ConstraintLayout

  9. 自定义的tabBarController的几种方法

    本文转载自:http://blog.sina.com.cn/s/blog_79c5bdc30100t88i.html 我自己实现的一种可以很方便的实现更换TabBarController图片的方法,代 ...

  10. SD卡 TF卡 接口引脚定义