zoukankan      html  css  js  c++  java
  • Android的UI两大基石

        说到Android的UI就不得不从一切的开始View开始说。
        让我们从Android Developer上的View的Overview和UI Overview来开始吧。
       
    Class Overview
        This class represents the basic building block for user interface components. A View occupies a rectangular area on the screen and is responsible for drawing and event handling. View is the base class for widgets, which are used to create interactive UI components (buttons, text fields, etc.). The ViewGroup subclass is the base class for layouts, which are invisible containers that hold other Views (or other ViewGroups) and define their layout properties.
        UI Overview
        All user interface elements in an Android app are built using View and ViewGroup objects. A View is an object that draws something on the screen that the user can interact with. A ViewGroup is an object that holds other View (and ViewGroup) objects in order to define the layout of the interface.
        Android provides a collection of both View and ViewGroup subclasses that offer you common input controls (such as buttons and text fields) and various layout models (such as a linear or relative layout).
        通过这两段Overview,我们了解到View是UI的最基本组件,是所有控件布局的超类。它是一切开始的基本。
        接着,该说到ViewGroup了。
        java.lang.Object
           ---android.view.View
                ---android.view.ViewGroup
        Class Overview
        A ViewGroup is a special view that can contain other views (called children.) The view group is the base class for layouts and views containers. This class also defines the ViewGroup.LayoutParams class which serves as the base class for layouts parameters.
        ViewGroup继承自View,是一类特别的View,特别是因为他能包含其他View,是作为一种容器而存在。
        下面要引用一张Android Developer上经典的老图了:




        这张图说明View和ViewGroup是如何组合成一个完整的视图的,这里使用了一种叫做组合的设计模式。我们来看看这种设计模式在wiki上的定义:
        组合模式:把多个对象组成树状结构来表示局部与整体,这样用户可以一样的对待单个对象和对象的组合。
        View和ViewGroup就是基于这种设计模式的设计的,好处在于对ViewGroup来说它将它的子节点全都当成View而不关心它子节点到底是View还是ViewGroup。
        View和ViewGroup组成了Android的UI的基石,UI设计也就是设计出一棵View树。

    ---------------------------------------------------------------------------------------------------------------
        如果文中有任何错误,欢迎指出。
     
  • 相关阅读:
    C盘与D盘中间有个恢复分区,导致C盘不能扩展卷解决
    Win下,QT控制台无输出解决
    QT与ECharts交互,绘制曲线图
    博客园好看的自定义主题
    Qt5之控件在初始化时就触发了槽函数的问题解决方案
    使用QCustomPlot,跟随鼠标动态显示线上点的值
    QCustomPlot下setTickLabelType()函数在新版本被移除如何解决
    记一次QT使用QAxWidget打开.html文件调用显示离线百度地图不能缩放,自定义图片不能显示解决方法
    使用QPainter绘制汽车仪表盘,动态显示
    QT下使用百度地图js,发送角度值给js使小车根据角度值调整车头方向
  • 原文地址:https://www.cnblogs.com/keanuyaoo/p/3328923.html
Copyright © 2011-2022 走看看