Android4.2.2 Gallery2源码分析(2)——发现Gallery.java
来源:互联网 发布:企业宣传制作软件 编辑:程序博客网 时间:2024/04/30 15:18
上文中,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"
<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>
<?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
- Android4.2.2 Gallery2源码分析(2)——发现Gallery.java
- Android4.2.2 Gallery2源码分析(3)——分析Gallery.java
- Android4.2.2 Gallery2源码分析(3)——分析Gallery.java
- Android4.2.2 Gallery2源码分析(11)——Gallery的层次结构图
- Android4.2.2 Gallery2源码分析(11)——Gallery的层次结构图
- Android4.2.2 Gallery2源码分析(4)——GLCanvas.java
- Android4.2.2 Gallery2源码分析(5)——GLCanvasImpl.java
- Android4.2.2 Gallery2源码分析(6)——GLView.java
- Android4.2.2 Gallery2源码分析(4)——GLCanvas.java
- Android4.2.2 Gallery2源码分析(5)——GLCanvasImpl.java
- Android4.2.2 Gallery2源码分析(6)——GLView.java
- Android4.2.2 Gallery2源码分析(1)——从布局入手
- Android4.2.2 Gallery2源码分析(7)——canvas的调用堆栈
- Android4.2.2 Gallery2源码分析(8)——假装的Activity
- Android4.2.2 Gallery2源码分析(9)——三个界面的跳转
- Android4.2.2 Gallery2源码分析(10)——Activity于View的结合
- Android4.2.2 Gallery2源码分析(1)——从布局入手 .
- javascript深入理解js闭包
- Python Tkinter Grid布局管理器详解
- CentOS下用Tomcat+Zookeeper+Nginx+Solr完美搭建SolrCloud平台(一)
- 登录时记住密码
- js闭包总结
- Android4.2.2 Gallery2源码分析(2)——发现Gallery.java
- CSS中行间距问题
- C#关于构造函数初始化器的使用
- Java里面是怎么解决没有链表这个问题的啊?
- oracle 建立表空间
- JComboBox,JList
- gridview自定义添加一列
- 黑马程序员_java基础_Day2(上)
- ajaxSubmit 提交表单实现图片上传