zoukankan      html  css  js  c++  java
  • android view源码(翻译头部1)

    前言:仔细阅读view源码头部的注释,会发现一些技术点早就在这里了。

    1.view头文件的翻译

    This class represents the basic building block for user interface components.
    当前类是用户页面组件的基本构建模块。(view是页面的基本)

    A View occupies a rectangular area on the screen and is responsible for drawing and event handling.
    视图占有屏幕矩形区域并且负责绘制和事件处理(view的功能:在屏幕矩形区域绘制视图以及视图的事件处理)

    View is the base class for <em>widgets</em>, which are used to create interactive UI components (buttons, text fields, etc.).
    View(widgets的基类)是被用来创建交互式UI的组件

    The {@link android.view.ViewGroup} subclass is the base class for <em>layouts</em>, which are invisible containers that hold other Views (or other ViewGroups) and define their layout properties.
    ViewGroup(view的子类,layout的基类)是不可见的容器并且包含其它的views/viewgroups,它定义了layout的属性。

    Developer Guides
    For information about using this class to develop your application's user interface,
    read the <a href="{@docRoot}guide/topics/ui/index.html">User Interface</a> developer guide.
    国内链接地址:https://developer.android.google.cn/guide/topics/ui/index.html

    U
    seing
    All of the views in a window are arranged in a single tree.
    窗口中的所有视图都排列在一棵树中

    You can add views either from code or by specifying a tree of views in one or more XML layout files.
    可以通过代码或通过在一个或多个XML布局中指定视图树来添加视图

    There are many specialized subclasses of views that act as controls or are capable of displaying text, images, or other content.
    有许多专门的视图子类可以充当控件,或者可以显示文本,图像或其他内容。

    Once you have created a tree of views, there are typically a few types of common operations you may wish to perform:
    创建视图树后,通常可能需要执行几种类型的常见操作:比如为textview设置text

    The available properties and the methods that set them will vary among the different subclasses of views.
    视图的不同子类会有不同的可用属性和设置它们的方法
    Note that properties that are known at build time can be set in the XML layout files
    请注意,可以在XML布局文件中设置*在构建时已知的属性*
    set focus

    The framework will handle moving focus in response to user input. To force focus to a specific view, call {@link #requestFocus}
    该框架将响应用户输入来处理移动焦点。 想强制聚焦到特定视图,参考* {@link #requestFocus}。
    Set up listeners
    Views allow clients to set listeners that will be notified when something interesting happens to the view. 
    视图允许客户端设置监听*当视图发生有趣的事情时通知

    For example, all views will let you set a listener to be notified when the view gains or loses focus.
    例如,所有视图将使您设置一个监听,以在该视图获得或失去焦点时得到通知

    You can register such a listener using {@link #setOnFocusChangeListener(android.view.View.OnFocusChangeListener)}.
    焦点的监听是setOnFoucusChangeListener

    Other view subclasses offer more specialized listeners.For example, a Button exposes a listener to notify clients when the button is clicked.
    其他视图子类提供更多相应动作的监听 例如,当按钮被单击时,按钮*会公开一个监听以通知客户端

    Set visibility
    You can hide or show views using {@link #setVisibility(int)}

    Note: The Android framework is responsible for measuring, laying out and drawing views. You should not call methods that perform these actions on views yourself unless you are actually implementing a {@link android.view.ViewGroup}.
    注意:Android framework负责测量,布局和绘图视图。 除非实际实现的是{{link android.view.ViewGroup},否则不应自己对视图回调这些操作的方法

    Implementing a Custom View

    To implement a custom view, you will usually begin by providing overrides for some of the standard methods that the framework calls on all views.
    要实现自定义视图,通常首先需要为框架在所有视图上调用的某些标准方法提供重写

    You do
    not need to override all of these methods. In fact, you can start by just overriding {@link #onDraw(android.graphics.Canvas)}
    不需要重写所有这些方法。 实际上,可以只重写{@link #onDraw(android.graphics.Canvas)}

    Creation

    Constructors

    There is a form of the constructor that are called when the view is created from code and a form that is called when the view is inflated from a layout file. The second form should parse and apply any attributes defined in the layout file.
    当从代码创建视图时会调用构造函数的一种形式,而从布局文件扩展视图时会调用一种形式的构造函数。 第二种形式应该解析并应用布局文件中定义的所有属性
    Called after a view and all of its children has been inflated from XML {@link #onFinishInflate()}
    在视图及其所有子级都已从XML扩展后调用onFinishInflate(只有在布局文件中实例化才有会这个回调)
    Called to determine the size requirements for this view and all of its children. {@link #onMeasure(int, int)}
    调用以确定此视图及其所有子视图的大小要求
    Called when this view should assign a size and position to all of its children. {@link #onLayout(boolean, int, int, int, int)}
    视图应为其所有子view分配大小和位置时调用

    Called when the size of this view has changed.
    {@link #onSizeChanged(int, int, int, int)}
    当此视图的大小更改时调用

    Called when the view should render its content.
    {@link #onDraw(android.graphics.Canvas)}
    在视图应呈现其内容时调用

    Called when a new hardware key event occurs. {@link #onKeyDown(int, KeyEvent)}
    发生新的硬件按键事件时调用

    Called when a hardware key up event occurs.
    {@link #onKeyUp(int, KeyEvent)}
    发生硬件按键激活事件时调用
    Called when a trackball motion event occurs. {@link #onTrackballEvent(MotionEvent)}
    发生轨迹球运动事件时调用
    Called when a touch screen motion event occurs. {@link #onTouchEvent(MotionEvent)}
    发生触摸屏运动事件时调用
    Called when the view gains or loses focus. {@link #onFocusChanged(boolean, int, android.graphics.Rect)}
    当视图获得焦点或失去焦点时调用
    Called when the window containing the view gains or loses focus. {@link #onWindowFocusChanged(boolean)}
    当包含视图的窗口获得焦点或失去焦点时调用
    Called when the view is attached to a window. {@link #onAttachedToWindow()}
    当视图附加到窗口时调用
    Called when the view is detached from its window. {@link #onDetachedFromWindow}
    当视图从其窗口分离时调用


    Called when the visibility of the window containing the view has changed. {@link #onWindowVisibilityChanged(int)}
    当包含视图的窗口的可见性更改时调用
     
     
     

          关注本人公众号获取更多干货.

     
     
     
     
     



     
     
  • 相关阅读:
    Android Logcat使用技巧
    SqlClient使用存储过程并获取输出参数的指
    内存调试的东西D/dalvikvm( 809 ): GC_CONCURRENT freed
    android 读写sd卡的权限设置
    Android中EditText的使用方法持續更新
    RSL编译方式的FLEX站点出现#2046错误
    从网络读取数据并动态的显示在ListView中
    LEFT JOIN INNER JOIN 效率比较
    使用Installshield2009 在IIS6部署Asp.net mvc 应用程序
    Installshield2009中使用osql.exe执行数据库脚本
  • 原文地址:https://www.cnblogs.com/wangandroid/p/13402300.html
Copyright © 2011-2022 走看看