mirror of
https://github.com/github/codeql.git
synced 2025-12-17 17:23:36 +01:00
682 lines
29 KiB
Java
682 lines
29 KiB
Java
/*
|
|
* Copyright (C) 2006 The Android Open Source Project
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
package android.view;
|
|
|
|
import android.content.Context;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Calendar;
|
|
import java.util.Collection;
|
|
import java.util.Collections;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Locale;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* <p>
|
|
* 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 <em>widgets</em>, which are
|
|
* used to create interactive UI components (buttons, text fields, etc.). 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.
|
|
* </p>
|
|
*
|
|
* <div class="special reference">
|
|
* <h3>Developer Guides</h3>
|
|
* <p>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.
|
|
* </div>
|
|
*
|
|
* <a name="Using"></a>
|
|
* <h3>Using Views</h3>
|
|
* <p>
|
|
* 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. There are many specialized subclasses of views that act as controls or
|
|
* are capable of displaying text, images, or other content.
|
|
* </p>
|
|
* <p>
|
|
* Once you have created a tree of views, there are typically a few types of
|
|
* common operations you may wish to perform:
|
|
* <ul>
|
|
* <li><strong>Set properties:</strong> for example setting the text of a
|
|
* {@link android.widget.TextView}. 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.</li>
|
|
* <li><strong>Set focus:</strong> The framework will handle moving focus in
|
|
* response to user input. To force focus to a specific view, call
|
|
* {@link #requestFocus}.</li>
|
|
* <li><strong>Set up listeners:</strong> 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)}.
|
|
* Other view subclasses offer more specialized listeners. For example, a Button
|
|
* exposes a listener to notify clients when the button is clicked.</li>
|
|
* <li><strong>Set visibility:</strong> You can hide or show views using
|
|
* {@link #setVisibility(int)}.</li>
|
|
* </ul>
|
|
* </p>
|
|
* <p><em>
|
|
* 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}.
|
|
* </em></p>
|
|
*
|
|
* <a name="Lifecycle"></a>
|
|
* <h3>Implementing a Custom View</h3>
|
|
*
|
|
* <p>
|
|
* 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)}.
|
|
* <table border="2" width="85%" align="center" cellpadding="5">
|
|
* <thead>
|
|
* <tr><th>Category</th> <th>Methods</th> <th>Description</th></tr>
|
|
* </thead>
|
|
*
|
|
* <tbody>
|
|
* <tr>
|
|
* <td rowspan="2">Creation</td>
|
|
* <td>Constructors</td>
|
|
* <td>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.
|
|
* </td>
|
|
* </tr>
|
|
* <tr>
|
|
* <td><code>{@link #onFinishInflate()}</code></td>
|
|
* <td>Called after a view and all of its children has been inflated
|
|
* from XML.</td>
|
|
* </tr>
|
|
*
|
|
* <tr>
|
|
* <td rowspan="3">Layout</td>
|
|
* <td><code>{@link #onMeasure(int, int)}</code></td>
|
|
* <td>Called to determine the size requirements for this view and all
|
|
* of its children.
|
|
* </td>
|
|
* </tr>
|
|
* <tr>
|
|
* <td><code>{@link #onLayout(boolean, int, int, int, int)}</code></td>
|
|
* <td>Called when this view should assign a size and position to all
|
|
* of its children.
|
|
* </td>
|
|
* </tr>
|
|
* <tr>
|
|
* <td><code>{@link #onSizeChanged(int, int, int, int)}</code></td>
|
|
* <td>Called when the size of this view has changed.
|
|
* </td>
|
|
* </tr>
|
|
*
|
|
* <tr>
|
|
* <td>Drawing</td>
|
|
* <td><code>{@link #onDraw(android.graphics.Canvas)}</code></td>
|
|
* <td>Called when the view should render its content.
|
|
* </td>
|
|
* </tr>
|
|
*
|
|
* <tr>
|
|
* <td rowspan="4">Event processing</td>
|
|
* <td><code>{@link #onKeyDown(int, KeyEvent)}</code></td>
|
|
* <td>Called when a new hardware key event occurs.
|
|
* </td>
|
|
* </tr>
|
|
* <tr>
|
|
* <td><code>{@link #onKeyUp(int, KeyEvent)}</code></td>
|
|
* <td>Called when a hardware key up event occurs.
|
|
* </td>
|
|
* </tr>
|
|
* <tr>
|
|
* <td><code>{@link #onTrackballEvent(MotionEvent)}</code></td>
|
|
* <td>Called when a trackball motion event occurs.
|
|
* </td>
|
|
* </tr>
|
|
* <tr>
|
|
* <td><code>{@link #onTouchEvent(MotionEvent)}</code></td>
|
|
* <td>Called when a touch screen motion event occurs.
|
|
* </td>
|
|
* </tr>
|
|
*
|
|
* <tr>
|
|
* <td rowspan="2">Focus</td>
|
|
* <td><code>{@link #onFocusChanged(boolean, int, android.graphics.Rect)}</code></td>
|
|
* <td>Called when the view gains or loses focus.
|
|
* </td>
|
|
* </tr>
|
|
*
|
|
* <tr>
|
|
* <td><code>{@link #onWindowFocusChanged(boolean)}</code></td>
|
|
* <td>Called when the window containing the view gains or loses focus.
|
|
* </td>
|
|
* </tr>
|
|
*
|
|
* <tr>
|
|
* <td rowspan="3">Attaching</td>
|
|
* <td><code>{@link #onAttachedToWindow()}</code></td>
|
|
* <td>Called when the view is attached to a window.
|
|
* </td>
|
|
* </tr>
|
|
*
|
|
* <tr>
|
|
* <td><code>{@link #onDetachedFromWindow}</code></td>
|
|
* <td>Called when the view is detached from its window.
|
|
* </td>
|
|
* </tr>
|
|
*
|
|
* <tr>
|
|
* <td><code>{@link #onWindowVisibilityChanged(int)}</code></td>
|
|
* <td>Called when the visibility of the window containing the view
|
|
* has changed.
|
|
* </td>
|
|
* </tr>
|
|
* </tbody>
|
|
*
|
|
* </table>
|
|
* </p>
|
|
*
|
|
* <a name="IDs"></a>
|
|
* <h3>IDs</h3>
|
|
* Views may have an integer id associated with them. These ids are typically
|
|
* assigned in the layout XML files, and are used to find specific views within
|
|
* the view tree. A common pattern is to:
|
|
* <ul>
|
|
* <li>Define a Button in the layout file and assign it a unique ID.
|
|
* <pre>
|
|
* <Button
|
|
* android:id="@+id/my_button"
|
|
* android:layout_width="wrap_content"
|
|
* android:layout_height="wrap_content"
|
|
* android:text="@string/my_button_text"/>
|
|
* </pre></li>
|
|
* <li>From the onCreate method of an Activity, find the Button
|
|
* <pre class="prettyprint">
|
|
* Button myButton = findViewById(R.id.my_button);
|
|
* </pre></li>
|
|
* </ul>
|
|
* <p>
|
|
* View IDs need not be unique throughout the tree, but it is good practice to
|
|
* ensure that they are at least unique within the part of the tree you are
|
|
* searching.
|
|
* </p>
|
|
*
|
|
* <a name="Position"></a>
|
|
* <h3>Position</h3>
|
|
* <p>
|
|
* The geometry of a view is that of a rectangle. A view has a location,
|
|
* expressed as a pair of <em>left</em> and <em>top</em> coordinates, and
|
|
* two dimensions, expressed as a width and a height. The unit for location
|
|
* and dimensions is the pixel.
|
|
* </p>
|
|
*
|
|
* <p>
|
|
* It is possible to retrieve the location of a view by invoking the methods
|
|
* {@link #getLeft()} and {@link #getTop()}. The former returns the left, or X,
|
|
* coordinate of the rectangle representing the view. The latter returns the
|
|
* top, or Y, coordinate of the rectangle representing the view. These methods
|
|
* both return the location of the view relative to its parent. For instance,
|
|
* when getLeft() returns 20, that means the view is located 20 pixels to the
|
|
* right of the left edge of its direct parent.
|
|
* </p>
|
|
*
|
|
* <p>
|
|
* In addition, several convenience methods are offered to avoid unnecessary
|
|
* computations, namely {@link #getRight()} and {@link #getBottom()}.
|
|
* These methods return the coordinates of the right and bottom edges of the
|
|
* rectangle representing the view. For instance, calling {@link #getRight()}
|
|
* is similar to the following computation: <code>getLeft() + getWidth()</code>
|
|
* (see <a href="#SizePaddingMargins">Size</a> for more information about the width.)
|
|
* </p>
|
|
*
|
|
* <a name="SizePaddingMargins"></a>
|
|
* <h3>Size, padding and margins</h3>
|
|
* <p>
|
|
* The size of a view is expressed with a width and a height. A view actually
|
|
* possess two pairs of width and height values.
|
|
* </p>
|
|
*
|
|
* <p>
|
|
* The first pair is known as <em>measured width</em> and
|
|
* <em>measured height</em>. These dimensions define how big a view wants to be
|
|
* within its parent (see <a href="#Layout">Layout</a> for more details.) The
|
|
* measured dimensions can be obtained by calling {@link #getMeasuredWidth()}
|
|
* and {@link #getMeasuredHeight()}.
|
|
* </p>
|
|
*
|
|
* <p>
|
|
* The second pair is simply known as <em>width</em> and <em>height</em>, or
|
|
* sometimes <em>drawing width</em> and <em>drawing height</em>. These
|
|
* dimensions define the actual size of the view on screen, at drawing time and
|
|
* after layout. These values may, but do not have to, be different from the
|
|
* measured width and height. The width and height can be obtained by calling
|
|
* {@link #getWidth()} and {@link #getHeight()}.
|
|
* </p>
|
|
*
|
|
* <p>
|
|
* To measure its dimensions, a view takes into account its padding. The padding
|
|
* is expressed in pixels for the left, top, right and bottom parts of the view.
|
|
* Padding can be used to offset the content of the view by a specific amount of
|
|
* pixels. For instance, a left padding of 2 will push the view's content by
|
|
* 2 pixels to the right of the left edge. Padding can be set using the
|
|
* {@link #setPadding(int, int, int, int)} or {@link #setPaddingRelative(int, int, int, int)}
|
|
* method and queried by calling {@link #getPaddingLeft()}, {@link #getPaddingTop()},
|
|
* {@link #getPaddingRight()}, {@link #getPaddingBottom()}, {@link #getPaddingStart()},
|
|
* {@link #getPaddingEnd()}.
|
|
* </p>
|
|
*
|
|
* <p>
|
|
* Even though a view can define a padding, it does not provide any support for
|
|
* margins. However, view groups provide such a support. Refer to
|
|
* {@link android.view.ViewGroup} and
|
|
* {@link android.view.ViewGroup.MarginLayoutParams} for further information.
|
|
* </p>
|
|
*
|
|
* <a name="Layout"></a>
|
|
* <h3>Layout</h3>
|
|
* <p>
|
|
* Layout is a two pass process: a measure pass and a layout pass. The measuring
|
|
* pass is implemented in {@link #measure(int, int)} and is a top-down traversal
|
|
* of the view tree. Each view pushes dimension specifications down the tree
|
|
* during the recursion. At the end of the measure pass, every view has stored
|
|
* its measurements. The second pass happens in
|
|
* {@link #layout(int,int,int,int)} and is also top-down. During
|
|
* this pass each parent is responsible for positioning all of its children
|
|
* using the sizes computed in the measure pass.
|
|
* </p>
|
|
*
|
|
* <p>
|
|
* When a view's measure() method returns, its {@link #getMeasuredWidth()} and
|
|
* {@link #getMeasuredHeight()} values must be set, along with those for all of
|
|
* that view's descendants. A view's measured width and measured height values
|
|
* must respect the constraints imposed by the view's parents. This guarantees
|
|
* that at the end of the measure pass, all parents accept all of their
|
|
* children's measurements. A parent view may call measure() more than once on
|
|
* its children. For example, the parent may measure each child once with
|
|
* unspecified dimensions to find out how big they want to be, then call
|
|
* measure() on them again with actual numbers if the sum of all the children's
|
|
* unconstrained sizes is too big or too small.
|
|
* </p>
|
|
*
|
|
* <p>
|
|
* The measure pass uses two classes to communicate dimensions. The
|
|
* {@link MeasureSpec} class is used by views to tell their parents how they
|
|
* want to be measured and positioned. The base LayoutParams class just
|
|
* describes how big the view wants to be for both width and height. For each
|
|
* dimension, it can specify one of:
|
|
* <ul>
|
|
* <li> an exact number
|
|
* <li>MATCH_PARENT, which means the view wants to be as big as its parent
|
|
* (minus padding)
|
|
* <li> WRAP_CONTENT, which means that the view wants to be just big enough to
|
|
* enclose its content (plus padding).
|
|
* </ul>
|
|
* There are subclasses of LayoutParams for different subclasses of ViewGroup.
|
|
* For example, AbsoluteLayout has its own subclass of LayoutParams which adds
|
|
* an X and Y value.
|
|
* </p>
|
|
*
|
|
* <p>
|
|
* MeasureSpecs are used to push requirements down the tree from parent to
|
|
* child. A MeasureSpec can be in one of three modes:
|
|
* <ul>
|
|
* <li>UNSPECIFIED: This is used by a parent to determine the desired dimension
|
|
* of a child view. For example, a LinearLayout may call measure() on its child
|
|
* with the height set to UNSPECIFIED and a width of EXACTLY 240 to find out how
|
|
* tall the child view wants to be given a width of 240 pixels.
|
|
* <li>EXACTLY: This is used by the parent to impose an exact size on the
|
|
* child. The child must use this size, and guarantee that all of its
|
|
* descendants will fit within this size.
|
|
* <li>AT_MOST: This is used by the parent to impose a maximum size on the
|
|
* child. The child must guarantee that it and all of its descendants will fit
|
|
* within this size.
|
|
* </ul>
|
|
* </p>
|
|
*
|
|
* <p>
|
|
* To initiate a layout, call {@link #requestLayout}. This method is typically
|
|
* called by a view on itself when it believes that is can no longer fit within
|
|
* its current bounds.
|
|
* </p>
|
|
*
|
|
* <a name="Drawing"></a>
|
|
* <h3>Drawing</h3>
|
|
* <p>
|
|
* Drawing is handled by walking the tree and recording the drawing commands of
|
|
* any View that needs to update. After this, the drawing commands of the
|
|
* entire tree are issued to screen, clipped to the newly damaged area.
|
|
* </p>
|
|
*
|
|
* <p>
|
|
* The tree is largely recorded and drawn in order, with parents drawn before
|
|
* (i.e., behind) their children, with siblings drawn in the order they appear
|
|
* in the tree. If you set a background drawable for a View, then the View will
|
|
* draw it before calling back to its <code>onDraw()</code> method. The child
|
|
* drawing order can be overridden with
|
|
* {@link ViewGroup#setChildrenDrawingOrderEnabled(boolean) custom child drawing order}
|
|
* in a ViewGroup, and with {@link #setZ(float)} custom Z values} set on Views.
|
|
* </p>
|
|
*
|
|
* <p>
|
|
* To force a view to draw, call {@link #invalidate()}.
|
|
* </p>
|
|
*
|
|
* <a name="EventHandlingThreading"></a>
|
|
* <h3>Event Handling and Threading</h3>
|
|
* <p>
|
|
* The basic cycle of a view is as follows:
|
|
* <ol>
|
|
* <li>An event comes in and is dispatched to the appropriate view. The view
|
|
* handles the event and notifies any listeners.</li>
|
|
* <li>If in the course of processing the event, the view's bounds may need
|
|
* to be changed, the view will call {@link #requestLayout()}.</li>
|
|
* <li>Similarly, if in the course of processing the event the view's appearance
|
|
* may need to be changed, the view will call {@link #invalidate()}.</li>
|
|
* <li>If either {@link #requestLayout()} or {@link #invalidate()} were called,
|
|
* the framework will take care of measuring, laying out, and drawing the tree
|
|
* as appropriate.</li>
|
|
* </ol>
|
|
* </p>
|
|
*
|
|
* <p><em>Note: The entire view tree is single threaded. You must always be on
|
|
* the UI thread when calling any method on any view.</em>
|
|
* If you are doing work on other threads and want to update the state of a view
|
|
* from that thread, you should use a {@link Handler}.
|
|
* </p>
|
|
*
|
|
* <a name="FocusHandling"></a>
|
|
* <h3>Focus Handling</h3>
|
|
* <p>
|
|
* The framework will handle routine focus movement in response to user input.
|
|
* This includes changing the focus as views are removed or hidden, or as new
|
|
* views become available. Views indicate their willingness to take focus
|
|
* through the {@link #isFocusable} method. To change whether a view can take
|
|
* focus, call {@link #setFocusable(boolean)}. When in touch mode (see notes below)
|
|
* views indicate whether they still would like focus via {@link #isFocusableInTouchMode}
|
|
* and can change this via {@link #setFocusableInTouchMode(boolean)}.
|
|
* </p>
|
|
* <p>
|
|
* Focus movement is based on an algorithm which finds the nearest neighbor in a
|
|
* given direction. In rare cases, the default algorithm may not match the
|
|
* intended behavior of the developer. In these situations, you can provide
|
|
* explicit overrides by using these XML attributes in the layout file:
|
|
* <pre>
|
|
* nextFocusDown
|
|
* nextFocusLeft
|
|
* nextFocusRight
|
|
* nextFocusUp
|
|
* </pre>
|
|
* </p>
|
|
*
|
|
*
|
|
* <p>
|
|
* To get a particular view to take focus, call {@link #requestFocus()}.
|
|
* </p>
|
|
*
|
|
* <a name="TouchMode"></a>
|
|
* <h3>Touch Mode</h3>
|
|
* <p>
|
|
* When a user is navigating a user interface via directional keys such as a D-pad, it is
|
|
* necessary to give focus to actionable items such as buttons so the user can see
|
|
* what will take input. If the device has touch capabilities, however, and the user
|
|
* begins interacting with the interface by touching it, it is no longer necessary to
|
|
* always highlight, or give focus to, a particular view. This motivates a mode
|
|
* for interaction named 'touch mode'.
|
|
* </p>
|
|
* <p>
|
|
* For a touch capable device, once the user touches the screen, the device
|
|
* will enter touch mode. From this point onward, only views for which
|
|
* {@link #isFocusableInTouchMode} is true will be focusable, such as text editing widgets.
|
|
* Other views that are touchable, like buttons, will not take focus when touched; they will
|
|
* only fire the on click listeners.
|
|
* </p>
|
|
* <p>
|
|
* Any time a user hits a directional key, such as a D-pad direction, the view device will
|
|
* exit touch mode, and find a view to take focus, so that the user may resume interacting
|
|
* with the user interface without touching the screen again.
|
|
* </p>
|
|
* <p>
|
|
* The touch mode state is maintained across {@link android.app.Activity}s. Call
|
|
* {@link #isInTouchMode} to see whether the device is currently in touch mode.
|
|
* </p>
|
|
*
|
|
* <a name="Scrolling"></a>
|
|
* <h3>Scrolling</h3>
|
|
* <p>
|
|
* The framework provides basic support for views that wish to internally
|
|
* scroll their content. This includes keeping track of the X and Y scroll
|
|
* offset as well as mechanisms for drawing scrollbars. See
|
|
* {@link #scrollBy(int, int)}, {@link #scrollTo(int, int)}, and
|
|
* {@link #awakenScrollBars()} for more details.
|
|
* </p>
|
|
*
|
|
* <a name="Tags"></a>
|
|
* <h3>Tags</h3>
|
|
* <p>
|
|
* Unlike IDs, tags are not used to identify views. Tags are essentially an
|
|
* extra piece of information that can be associated with a view. They are most
|
|
* often used as a convenience to store data related to views in the views
|
|
* themselves rather than by putting them in a separate structure.
|
|
* </p>
|
|
* <p>
|
|
* Tags may be specified with character sequence values in layout XML as either
|
|
* a single tag using the {@link android.R.styleable#View_tag android:tag}
|
|
* attribute or multiple tags using the {@code <tag>} child element:
|
|
* <pre>
|
|
* <View ...
|
|
* android:tag="@string/mytag_value" />
|
|
* <View ...>
|
|
* <tag android:id="@+id/mytag"
|
|
* android:value="@string/mytag_value" />
|
|
* </View>
|
|
* </pre>
|
|
* </p>
|
|
* <p>
|
|
* Tags may also be specified with arbitrary objects from code using
|
|
* {@link #setTag(Object)} or {@link #setTag(int, Object)}.
|
|
* </p>
|
|
*
|
|
* <a name="Themes"></a>
|
|
* <h3>Themes</h3>
|
|
* <p>
|
|
* By default, Views are created using the theme of the Context object supplied
|
|
* to their constructor; however, a different theme may be specified by using
|
|
* the {@link android.R.styleable#View_theme android:theme} attribute in layout
|
|
* XML or by passing a {@link ContextThemeWrapper} to the constructor from
|
|
* code.
|
|
* </p>
|
|
* <p>
|
|
* When the {@link android.R.styleable#View_theme android:theme} attribute is
|
|
* used in XML, the specified theme is applied on top of the inflation
|
|
* context's theme (see {@link LayoutInflater}) and used for the view itself as
|
|
* well as any child elements.
|
|
* </p>
|
|
* <p>
|
|
* In the following example, both views will be created using the Material dark
|
|
* color scheme; however, because an overlay theme is used which only defines a
|
|
* subset of attributes, the value of
|
|
* {@link android.R.styleable#Theme_colorAccent android:colorAccent} defined on
|
|
* the inflation context's theme (e.g. the Activity theme) will be preserved.
|
|
* <pre>
|
|
* <LinearLayout
|
|
* ...
|
|
* android:theme="@android:theme/ThemeOverlay.Material.Dark">
|
|
* <View ...>
|
|
* </LinearLayout>
|
|
* </pre>
|
|
* </p>
|
|
*
|
|
* <a name="Properties"></a>
|
|
* <h3>Properties</h3>
|
|
* <p>
|
|
* The View class exposes an {@link #ALPHA} property, as well as several transform-related
|
|
* properties, such as {@link #TRANSLATION_X} and {@link #TRANSLATION_Y}. These properties are
|
|
* available both in the {@link Property} form as well as in similarly-named setter/getter
|
|
* methods (such as {@link #setAlpha(float)} for {@link #ALPHA}). These properties can
|
|
* be used to set persistent state associated with these rendering-related properties on the view.
|
|
* The properties and methods can also be used in conjunction with
|
|
* {@link android.animation.Animator Animator}-based animations, described more in the
|
|
* <a href="#Animation">Animation</a> section.
|
|
* </p>
|
|
*
|
|
* <a name="Animation"></a>
|
|
* <h3>Animation</h3>
|
|
* <p>
|
|
* Starting with Android 3.0, the preferred way of animating views is to use the
|
|
* {@link android.animation} package APIs. These {@link android.animation.Animator Animator}-based
|
|
* classes change actual properties of the View object, such as {@link #setAlpha(float) alpha} and
|
|
* {@link #setTranslationX(float) translationX}. This behavior is contrasted to that of the pre-3.0
|
|
* {@link android.view.animation.Animation Animation}-based classes, which instead animate only
|
|
* how the view is drawn on the display. In particular, the {@link ViewPropertyAnimator} class
|
|
* makes animating these View properties particularly easy and efficient.
|
|
* </p>
|
|
* <p>
|
|
* Alternatively, you can use the pre-3.0 animation classes to animate how Views are rendered.
|
|
* You can attach an {@link Animation} object to a view using
|
|
* {@link #setAnimation(Animation)} or
|
|
* {@link #startAnimation(Animation)}. The animation can alter the scale,
|
|
* rotation, translation and alpha of a view over time. If the animation is
|
|
* attached to a view that has children, the animation will affect the entire
|
|
* subtree rooted by that node. When an animation is started, the framework will
|
|
* take care of redrawing the appropriate views until the animation completes.
|
|
* </p>
|
|
*
|
|
* <a name="Security"></a>
|
|
* <h3>Security</h3>
|
|
* <p>
|
|
* Sometimes it is essential that an application be able to verify that an action
|
|
* is being performed with the full knowledge and consent of the user, such as
|
|
* granting a permission request, making a purchase or clicking on an advertisement.
|
|
* Unfortunately, a malicious application could try to spoof the user into
|
|
* performing these actions, unaware, by concealing the intended purpose of the view.
|
|
* As a remedy, the framework offers a touch filtering mechanism that can be used to
|
|
* improve the security of views that provide access to sensitive functionality.
|
|
* </p><p>
|
|
* To enable touch filtering, call {@link #setFilterTouchesWhenObscured(boolean)} or set the
|
|
* android:filterTouchesWhenObscured layout attribute to true. When enabled, the framework
|
|
* will discard touches that are received whenever the view's window is obscured by
|
|
* another visible window. As a result, the view will not receive touches whenever a
|
|
* toast, dialog or other window appears above the view's window.
|
|
* </p><p>
|
|
* For more fine-grained control over security, consider overriding the
|
|
* {@link #onFilterTouchEventForSecurity(MotionEvent)} method to implement your own
|
|
* security policy. See also {@link MotionEvent#FLAG_WINDOW_IS_OBSCURED}.
|
|
* </p>
|
|
*
|
|
* @attr ref android.R.styleable#View_accessibilityHeading
|
|
* @attr ref android.R.styleable#View_alpha
|
|
* @attr ref android.R.styleable#View_background
|
|
* @attr ref android.R.styleable#View_clickable
|
|
* @attr ref android.R.styleable#View_contentDescription
|
|
* @attr ref android.R.styleable#View_drawingCacheQuality
|
|
* @attr ref android.R.styleable#View_duplicateParentState
|
|
* @attr ref android.R.styleable#View_id
|
|
* @attr ref android.R.styleable#View_requiresFadingEdge
|
|
* @attr ref android.R.styleable#View_fadeScrollbars
|
|
* @attr ref android.R.styleable#View_fadingEdgeLength
|
|
* @attr ref android.R.styleable#View_filterTouchesWhenObscured
|
|
* @attr ref android.R.styleable#View_fitsSystemWindows
|
|
* @attr ref android.R.styleable#View_isScrollContainer
|
|
* @attr ref android.R.styleable#View_focusable
|
|
* @attr ref android.R.styleable#View_focusableInTouchMode
|
|
* @attr ref android.R.styleable#View_focusedByDefault
|
|
* @attr ref android.R.styleable#View_hapticFeedbackEnabled
|
|
* @attr ref android.R.styleable#View_keepScreenOn
|
|
* @attr ref android.R.styleable#View_keyboardNavigationCluster
|
|
* @attr ref android.R.styleable#View_layerType
|
|
* @attr ref android.R.styleable#View_layoutDirection
|
|
* @attr ref android.R.styleable#View_longClickable
|
|
* @attr ref android.R.styleable#View_minHeight
|
|
* @attr ref android.R.styleable#View_minWidth
|
|
* @attr ref android.R.styleable#View_nextClusterForward
|
|
* @attr ref android.R.styleable#View_nextFocusDown
|
|
* @attr ref android.R.styleable#View_nextFocusLeft
|
|
* @attr ref android.R.styleable#View_nextFocusRight
|
|
* @attr ref android.R.styleable#View_nextFocusUp
|
|
* @attr ref android.R.styleable#View_onClick
|
|
* @attr ref android.R.styleable#View_outlineSpotShadowColor
|
|
* @attr ref android.R.styleable#View_outlineAmbientShadowColor
|
|
* @attr ref android.R.styleable#View_padding
|
|
* @attr ref android.R.styleable#View_paddingHorizontal
|
|
* @attr ref android.R.styleable#View_paddingVertical
|
|
* @attr ref android.R.styleable#View_paddingBottom
|
|
* @attr ref android.R.styleable#View_paddingLeft
|
|
* @attr ref android.R.styleable#View_paddingRight
|
|
* @attr ref android.R.styleable#View_paddingTop
|
|
* @attr ref android.R.styleable#View_paddingStart
|
|
* @attr ref android.R.styleable#View_paddingEnd
|
|
* @attr ref android.R.styleable#View_saveEnabled
|
|
* @attr ref android.R.styleable#View_rotation
|
|
* @attr ref android.R.styleable#View_rotationX
|
|
* @attr ref android.R.styleable#View_rotationY
|
|
* @attr ref android.R.styleable#View_scaleX
|
|
* @attr ref android.R.styleable#View_scaleY
|
|
* @attr ref android.R.styleable#View_scrollX
|
|
* @attr ref android.R.styleable#View_scrollY
|
|
* @attr ref android.R.styleable#View_scrollbarSize
|
|
* @attr ref android.R.styleable#View_scrollbarStyle
|
|
* @attr ref android.R.styleable#View_scrollbars
|
|
* @attr ref android.R.styleable#View_scrollbarDefaultDelayBeforeFade
|
|
* @attr ref android.R.styleable#View_scrollbarFadeDuration
|
|
* @attr ref android.R.styleable#View_scrollbarTrackHorizontal
|
|
* @attr ref android.R.styleable#View_scrollbarThumbHorizontal
|
|
* @attr ref android.R.styleable#View_scrollbarThumbVertical
|
|
* @attr ref android.R.styleable#View_scrollbarTrackVertical
|
|
* @attr ref android.R.styleable#View_scrollbarAlwaysDrawHorizontalTrack
|
|
* @attr ref android.R.styleable#View_scrollbarAlwaysDrawVerticalTrack
|
|
* @attr ref android.R.styleable#View_stateListAnimator
|
|
* @attr ref android.R.styleable#View_transitionName
|
|
* @attr ref android.R.styleable#View_soundEffectsEnabled
|
|
* @attr ref android.R.styleable#View_tag
|
|
* @attr ref android.R.styleable#View_textAlignment
|
|
* @attr ref android.R.styleable#View_textDirection
|
|
* @attr ref android.R.styleable#View_transformPivotX
|
|
* @attr ref android.R.styleable#View_transformPivotY
|
|
* @attr ref android.R.styleable#View_translationX
|
|
* @attr ref android.R.styleable#View_translationY
|
|
* @attr ref android.R.styleable#View_translationZ
|
|
* @attr ref android.R.styleable#View_visibility
|
|
* @attr ref android.R.styleable#View_theme
|
|
*
|
|
* @see android.view.ViewGroup
|
|
*/
|
|
public class View {
|
|
|
|
/**
|
|
* Simple constructor to use when creating a view from code.
|
|
*
|
|
* @param context The Context the view is running in, through which it can
|
|
* access the current theme, resources, etc.
|
|
*/
|
|
public View(Context context) {
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |