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这个类

  • 相关阅读:
    Redis
    cz_health_day13项目实战
    cz_health_day11
    cz_health_day10
    cz_health_day09
    cz_health_day08
    MySQL8管理系列之二:从5.5升级到8的问题处理
    MySQL8管理系列之一:Mysql 8.0以后版本的安装
    MySQL 5.5.x 数据库导入到 8.0.x 服务器
    修改Mysql 8.0版本的默认数据库目录
  • 原文地址:https://www.cnblogs.com/keanuyaoo/p/3398014.html
Copyright © 2011-2022 走看看