zoukankan      html  css  js  c++  java
  • Android4.2.2 Gallery2源码分析(2)——发现Gallery.java

    上文中,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这个类

  • 相关阅读:
    SX知识学习——sources
    SX知识学习——TCGA(转)
    SX知识学习——WES(转)
    SX知识学习——CHIPseq(转+总结)
    编译软件安装——VS2010
    数据库知识学习——mysql
    计算机知识学习——操作系统
    计算机知识学习——计算机组成原理
    Scrapy 中文手册 0.25 文档
    python Requests 库
  • 原文地址:https://www.cnblogs.com/keanuyaoo/p/3398014.html
Copyright © 2011-2022 走看看