1.
Declaring Layout
To measure its dimensions, a view takes into account its padding.
Padding can be used to offset the content of the view by a specific amount of
pixels
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 ViewGroup
and ViewGroup.MarginLayoutParams
for further information
It is possible to retrieve the location of a view by invoking the methods
getLeft()
and getTop()
.
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.
In general, the XML vocabulary for declaring UI elements closely follows the
structure and naming of the classes and methods, where element names correspond
to class names and attribute names correspond to methods
Handling UI Events
onTouch()
- This returns a boolean to indicate whether your listener consumes this event.
The important thing is that this event can have multiple actions that follow
each other. So, if you return false
when the down action event is
received, you indicate that you have not consumed the event and are also not
interested in subsequent actions from this event. Thus, you will not be called
for any other actions within the event, such as a finger gesture, or the
eventual up action event.
Note:
Android will call event handlers first and
then the appropriate default handlers from the class definition second. As such,
returning true
from these event listeners will stop the propagation of
the event to other event listeners and will also block the callback to the
default event handler in the View. So be certain that you want to terminate the
event when you return true
.
Service API changes starting with Android 2.0
Consider this typical scenario:
- An application calls startService().
- That service gets onCreate(), onStart(), and then spawns a background thread
to do some work.
- The system is tight on memory, so has to kill the currently running service.
- Later when memory is free, the service is restarted, and gets onCreate()
called but not onStart() because there has not been another call to
startService() with a new Intent command to send it.
Now the service will sit there created, not realizing it used to be doing
some work, and so not knowing it should stop itself at some point.
To address this, in Android 2.0 Service.onStart() as been deprecated (though
still exists and operates as it used to in previous versions of the platform).
It is replaced with a new Service.onStartCommand()
callback that allows the service to better control how the system should manage
it. The key part here is a new result code returned by the function, telling the
system what it should do with the service if its process is killed while it is
running:
Once you start targeting API version 5 or later, the default mode is
START_STICKY and you must be prepared to deal with onStart() or onStartCommand()
being called with a null Intent.
http://android-developers.blogspot.com/2010/02/service-api-changes-starting-with.html
分享到:
相关推荐
Brew_MP_Multiplatform_SDK_Release_Notes
android SDK 下 NotePad例子详解 自己结合博客对例子进行了分析
Intel Media SDK provides access to Intel® Quick Sync Video (hardware-accelerated video codecs in Intel® processors with integrated graphics), which helps developers achieve outstanding encoding, ...
Windows SDKWindows SDKWindows SDKWindows SDKWindows SDKWindows SDKWindows SDKWindows SDKWindows SDKWindows SDKWindows SDKWindows SDKWindows SDK
PPC SDK(CHS) Release Notes中文
大多数触摸屏都是Synaptics公司的。这是Synaptics公司提供的SDK 。
SDK教程 SDK教程 SDK教程 SDK教程 SDK教程 SDK教程 SDK教程 SDK教程 SDK教程 SDK教程 SDK教程
支付宝支付SDK alipay-trade-sdk alipay-sdk-java 支付宝支付SDK alipay-trade-sdk alipay-sdk-java 支付宝支付SDK alipay-trade-sdk alipay-sdk-java 支付宝支付SDK alipay-trade-sdk alipay-sdk-java
SDK入门教程SDK入门教程SDK入门教程SDK入门教程SDK入门教程SDK入门教程SDK入门教程SDK入门教程SDK入门教程SDK入门教程SDK入门教程SDK入门教程SDK入门教程SDK入门教程SDK入门教程SDK入门教程SDK入门教程SDK入门教程...
PlayStation®4 SDK 4.50Recommended Reading ListDevelopment EnvironmentWhat's New in LLVM 3.3 for PlayStation®4 ClangWhat's New in LLVM 3.4 for PlayStation®4 ClangWhat's New in LLVM 3.5 for ...
MTK-OpenWrt-3.10.14-SDK 开发文档
中控门禁SDK 供有需要的朋友们学习参考
其实这几个bug在安装SDK3.0后的Micro Framework SDK Release Notes.txt中已经有了说明。 主要有如下两个问题: (1) 非英文版VS2008安装SDK3.0后,在新建项目中无micro Framework选项 解决办法: If you are ...
alipay-sdk-java-allalipay-sdk-java-allalipay-sdk-java-allalipay-sdk-java-allalipay-sdk-java-allalipay-sdk-java-allalipay-sdk-java-allalipay-sdk-java-allalipay-sdk-java-allalipay-sdk-java-allalipay-sdk...
挪威雷达SDK。 Library for interfacing with one or more Navico Radars, controlling their functionality and converting the real time image data they output into an easily understandable image.
SDK和MFC介绍SDK和MFC介绍SDK和MFC介绍SDK和MFC介绍SDK和MFC介绍SDK和MFC介绍SDK和MFC介绍SDK和MFC介绍SDK和MFC介绍SDK和MFC介绍SDK和MFC介绍SDK和MFC介绍SDK和MFC介绍SDK和MFC介绍SDK和MFC介绍SDK和MFC介绍SDK和MFC...
奇门SDK/qimen sdk
Android SDK (SDK Platforms)-android-25.zip
aip-java-sdk-4.15.1aip-java-sdk-4.15.1aip-java-sdk-4.15.1aip-java-sdk-4.15.1aip-java-sdk-4.15.1aip-java-sdk-4.15.1aip-java-sdk-4.15.1aip-java-sdk-4.15.1aip-java-sdk-4.15.1aip-java-sdk-4.15.1aip-java-...