- 浏览: 506142 次
- 性别:
- 来自: 深圳
文章分类
- 全部博客 (200)
- java基础 (30)
- ajax (19)
- 乱写 (5)
- groovy (2)
- db (8)
- gwt (0)
- jee (2)
- 我关注的开源 (1)
- RIA AIR (1)
- spring (11)
- lucene (0)
- 工具 (10)
- 百科 (2)
- linux (6)
- android (40)
- 移动开发 (21)
- 代码片断 (15)
- tomcat (1)
- css (1)
- html5 (2)
- jquery (2)
- playframework (3)
- web (2)
- nio (3)
- design (1)
- nosql (3)
- 日志 (12)
- mysql (4)
- 图表 (1)
- python (3)
- ruby (1)
- git (0)
- hibernate (1)
- springboot (1)
- guava (1)
- mybatis (0)
- 工作问题 (3)
- php (1)
最新评论
-
linzm1990:
踩了很多坑啊。。。。
hibernate @Nofound 与@ManyToOne fetch lazy的问题 -
Ccccrrrrrr:
...
转: Spring boot 文件上传 -
rmzdb:
兄弟,你这个东西,在ie内核的浏览器,貌似不识别 文件名
工作问题:http下载文件,中文文件名在firefox下乱码问题 -
107x:
问题解决了,谢谢!
工作问题:http下载文件,中文文件名在firefox下乱码问题 -
klxqljq:
额鹅鹅鹅
android布局实现头尾固定, 中间多余内容可以滚动
因google总被墙. http://android-developers.blogspot.com/2009/04/updating-applications-for-on-screen.html
One of the major new features we are introducing in Android 1.5 is our Input Method Framework (IMF), which allows developers on-screen input methods such as software keyboards. This article will provide an overview of what Android input method editors (IMEs) are, and what an application developer needs to do to work well with them. The IMF allows for a new class of Android devices, such as those without a hardware keyboard, so it is important that your application work well with it to provide the users of such devices a great experience.
What is an input method?
The Android IMF is designed to support a variety of IMEs, including soft keyboard, hand-writing recognizers, and hard keyboard translators. Our focus, however, will be on soft keyboards, since this is the kind of input method that is currently part of the platform.
A user will usually access the current IME by tapping on a text view to edit, as shown here in the home screen:
The soft keyboard is positioned at the bottom of the screen over the application's window. To organize the available space between the application and IME, we use a few approaches; the one shown here is called pan and scan, and simply involves scrolling the application window around so that the currently focused view is visible. This is the default mode, since it is the safest for [size=medium]existing applications.
Most often the preferred screen layout is a resize, where the application's window is resized to be entirely visible. An example is shown here, when composing an e-mail message:
The size of the application window is changed so that none of it is hidden by the IME, allowing full access to both the application and IME. This of course only works for applications that have a resizeable area that can be reduced to make enough space, but the vertical space in this mode is actually no less than what is available in landscape orientation, so very often an application can already accommodate it.
The final major mode is fullscreen or extract mode. This is used when the IME is too large to reasonably share space with the underlying application. With the standard IMEs, you will only encounter this situation when the screen is in a landscape orientation, although other IMEs are free to use it whenever they desire. In this case the application window is left as-is, and the IME simply displays fullscreen on top of it, as shown here:
Because the IME is covering the application, it has its own editing area, which shows the text actually contained in the application. There are also some limited opportunities the application has to customize parts of the IME (the "done" button at the top and enter key label at the bottom) to improve the user experience.
Basic XML attributes for controlling IMEs
There are a number of things the system does to try to help existing applications work with IMEs as well as possible, such as:
There are also some simple things you can do in your application that will often greatly improve its user experience. Note that, except where explicitly mentioned, all of the things suggested here will not tie your application to Android 1.5 -- it will still work on older releases, which will simply ignore these new options.
Specifying each EditText control's input type
The most important thing for an application to do is use the new android:inputType attribute on each EditText, which provides much richer information about the text content. This attribute actually replaces many existing attributes (android:password, android:singleLine, android:numeric, android:phoneNumber, android:capitalize, android:autoText, android:editable); if you specify both, Cupcake devices will use the new android:inputType attribute and ignore the others.
The input type attribute has three pieces:
The class is the overall interpretation of characters. The currently supported classes are text (plain text), number (decimal number), phone (phone number), and datetime (a date or time).
The variation is a further refinement on the class. In the attribute you will normally specify the class and variant together, with the class as a prefix. For example, textEmailAddress is a text field where the user will enter something that is an e-mail address (foo@bar.com) so the key layout will have an '@' character in easy access, and numberSigned is a numeric field with a sign. If only the class is specified, then you get the default/generic variant.
Additional flags can be specified that supply further refinement. These flags are specific to a class. For example, some flags for the text class are textCapSentences, textAutoCorrect, and textMultiline.
As an example, here is the new EditText for the IM application's message text view:
A full description of all of the input types can be found in the documentation. It is important to make use of the correct input types that are available, so that the soft keyboard can use the optimal keyboard layout for the text the user will be entering.
Enabling resize mode and other window features
The next most important thing for you to do is specify the overall behavior of your window in relation to the input method. The most visible aspect of this is controlling resize vs. pan and scan mode, but there are other things you can do as well to improve your user experience.
You will usually control this behavior through the android:windowSoftInputMode attribute on each <activity> definition in your AndroidManifest.xml. Like the input type, there are a couple different pieces of data that can be specified here by combining them together:
A typical example of this field can be see in the edit contact activity, which ensures it is resized and automatically displays the IME for the user:
For non-activity windows, there is a new Window.setSoftInputMode() method that can be used to control their behavior. Note that calling this API will make your application incompatible with previous Android platforms.
Controlling the action buttons
The final customization we will look at is the "action" buttons in the IME. There are currently two types of actions:
These options are controlled with the android:imeOptions attribute on TextView. The value you supply here can be any combination of:
The previous IM application message view also provides an example of an interesting use of imeOptions, to specify the send action but not let it be shown on the enter key:
APIs for controlling IMEs
For more advanced control over the IME, there are a variety of new APIs you can use. Unless special care is taken (such as by using reflection), using these APIs will cause your application to be incompatible with previous versions of Android, and you should make sure you specify android:minSdkVersion="3" in your manifest.
The primary API is the new android.view.inputmethod.InputMethodManager class, which you can retrieve with Context.getSystemService(). It allows you to interact with the global input method state, such as explicitly hiding or showing the current IME's input area.
There are also new window flags controlling input method interaction, which you can control through the existing Window.addFlags() method and new Window.setSoftInputMode() method. The PopupWindow class has grown corresponding methods to control these options on its window. One thing in particular to be aware of is the new WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM constant, which is used to control whether a window is on top of or behind the current IME.
Most of the interaction between an active IME and application is done through the android.view.inputmethod.InputConnection class. This is the API an application implement, which an IME calls to perform the appropriate edit operations on the application. You won't normally need to worry about this, since TextView provides its own implementation for itself.
There are also a handful of new View APIs, the most important of these being onCreateInputConnection() which creates a new InputConnection for an IME (and fills in an android.view.inputmethod.EditorInfo structure with your input type, IME options, and other data); again, most developers won't need to worry about this, since TextView takes care of it for you.
One of the major new features we are introducing in Android 1.5 is our Input Method Framework (IMF), which allows developers on-screen input methods such as software keyboards. This article will provide an overview of what Android input method editors (IMEs) are, and what an application developer needs to do to work well with them. The IMF allows for a new class of Android devices, such as those without a hardware keyboard, so it is important that your application work well with it to provide the users of such devices a great experience.
What is an input method?
The Android IMF is designed to support a variety of IMEs, including soft keyboard, hand-writing recognizers, and hard keyboard translators. Our focus, however, will be on soft keyboards, since this is the kind of input method that is currently part of the platform.
A user will usually access the current IME by tapping on a text view to edit, as shown here in the home screen:
The soft keyboard is positioned at the bottom of the screen over the application's window. To organize the available space between the application and IME, we use a few approaches; the one shown here is called pan and scan, and simply involves scrolling the application window around so that the currently focused view is visible. This is the default mode, since it is the safest for [size=medium]existing applications.
Most often the preferred screen layout is a resize, where the application's window is resized to be entirely visible. An example is shown here, when composing an e-mail message:
The size of the application window is changed so that none of it is hidden by the IME, allowing full access to both the application and IME. This of course only works for applications that have a resizeable area that can be reduced to make enough space, but the vertical space in this mode is actually no less than what is available in landscape orientation, so very often an application can already accommodate it.
The final major mode is fullscreen or extract mode. This is used when the IME is too large to reasonably share space with the underlying application. With the standard IMEs, you will only encounter this situation when the screen is in a landscape orientation, although other IMEs are free to use it whenever they desire. In this case the application window is left as-is, and the IME simply displays fullscreen on top of it, as shown here:
Because the IME is covering the application, it has its own editing area, which shows the text actually contained in the application. There are also some limited opportunities the application has to customize parts of the IME (the "done" button at the top and enter key label at the bottom) to improve the user experience.
Basic XML attributes for controlling IMEs
There are a number of things the system does to try to help existing applications work with IMEs as well as possible, such as:
- Use pan and scan mode by default, unless it can reasonably guess that resize mode will work by the existence of lists, scroll views, etc.
- Analyze the various existing TextView attributes to guess at the kind of content (numbers, plain text, etc) to help the soft keyboard display an appropriate key layout.
- Assign a few default actions to the fullscreen IME, such as "next field" and "done".
There are also some simple things you can do in your application that will often greatly improve its user experience. Note that, except where explicitly mentioned, all of the things suggested here will not tie your application to Android 1.5 -- it will still work on older releases, which will simply ignore these new options.
Specifying each EditText control's input type
The most important thing for an application to do is use the new android:inputType attribute on each EditText, which provides much richer information about the text content. This attribute actually replaces many existing attributes (android:password, android:singleLine, android:numeric, android:phoneNumber, android:capitalize, android:autoText, android:editable); if you specify both, Cupcake devices will use the new android:inputType attribute and ignore the others.
The input type attribute has three pieces:
The class is the overall interpretation of characters. The currently supported classes are text (plain text), number (decimal number), phone (phone number), and datetime (a date or time).
The variation is a further refinement on the class. In the attribute you will normally specify the class and variant together, with the class as a prefix. For example, textEmailAddress is a text field where the user will enter something that is an e-mail address (foo@bar.com) so the key layout will have an '@' character in easy access, and numberSigned is a numeric field with a sign. If only the class is specified, then you get the default/generic variant.
Additional flags can be specified that supply further refinement. These flags are specific to a class. For example, some flags for the text class are textCapSentences, textAutoCorrect, and textMultiline.
As an example, here is the new EditText for the IM application's message text view:
<EditText android:id="@+id/edtInput" android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" android:inputType="textShortMessage|textAutoCorrect|textCapSentences|textMultiLine" android:imeOptions="actionSend|flagNoEnterAction" android:maxLines="4" android:maxLength="2000" android:hint="@string/compose_hint" />
A full description of all of the input types can be found in the documentation. It is important to make use of the correct input types that are available, so that the soft keyboard can use the optimal keyboard layout for the text the user will be entering.
Enabling resize mode and other window features
The next most important thing for you to do is specify the overall behavior of your window in relation to the input method. The most visible aspect of this is controlling resize vs. pan and scan mode, but there are other things you can do as well to improve your user experience.
You will usually control this behavior through the android:windowSoftInputMode attribute on each <activity> definition in your AndroidManifest.xml. Like the input type, there are a couple different pieces of data that can be specified here by combining them together:
- The window adjustment mode is specified with either adjustResize or adjustPan. It is highly recommended that you always specify one or the other.
- You can further control whether the IME will be shown automatically when your activity is displayed and other situations where the user moves to it. The system won't automatically show an IME by default, but in some cases it can be convenient for the user if an application enables this behavior. You can request this with stateVisible. There are also a number of other state options for finer-grained control that you can find in the documentation.
A typical example of this field can be see in the edit contact activity, which ensures it is resized and automatically displays the IME for the user:
<activity name="EditContactActivity" android:windowSoftInputMode="stateVisible|adjustResize"> ... </activity>
For non-activity windows, there is a new Window.setSoftInputMode() method that can be used to control their behavior. Note that calling this API will make your application incompatible with previous Android platforms.
Controlling the action buttons
The final customization we will look at is the "action" buttons in the IME. There are currently two types of actions:
- The enter key on a soft keyboard is typically bound to an action when not operating on a mult-line edit text. For example, on the G1 pressing the hard enter key will typically move to the next field or the application will intercept it to execute an action; with a soft keyboard, this overloading of the enter key remains, since the enter button just sends an enter key event.
- When in fullscreen mode, an IME may also put an additional action button to the right of the text being edited, giving the user quick access to a common application operation.
These options are controlled with the android:imeOptions attribute on TextView. The value you supply here can be any combination of:
- One of the pre-defined action constants (actionGo, actionSearch, actionSend, actionNext, actionDone). If none of these are specified, the system will infer either actionNext or actionDone depending on whether there is a focusable field after this one; you can explicitly force no action with actionNone.
- The flagNoEnterAction option tells the IME that the action should not be available on the enter key, even if the text itself is not multi-line. This avoids having unrecoverable actions like (send) that can be accidentally touched by the user while typing.
- The flagNoAccessoryAction removes the action button from the text area, leaving more room for text. The flagNoExtractUi completely removes the text area, allowing the application to be seen behind it.
The previous IM application message view also provides an example of an interesting use of imeOptions, to specify the send action but not let it be shown on the enter key:
android:imeOptions="actionSend|flagNoEnterAction"
APIs for controlling IMEs
For more advanced control over the IME, there are a variety of new APIs you can use. Unless special care is taken (such as by using reflection), using these APIs will cause your application to be incompatible with previous versions of Android, and you should make sure you specify android:minSdkVersion="3" in your manifest.
The primary API is the new android.view.inputmethod.InputMethodManager class, which you can retrieve with Context.getSystemService(). It allows you to interact with the global input method state, such as explicitly hiding or showing the current IME's input area.
There are also new window flags controlling input method interaction, which you can control through the existing Window.addFlags() method and new Window.setSoftInputMode() method. The PopupWindow class has grown corresponding methods to control these options on its window. One thing in particular to be aware of is the new WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM constant, which is used to control whether a window is on top of or behind the current IME.
Most of the interaction between an active IME and application is done through the android.view.inputmethod.InputConnection class. This is the API an application implement, which an IME calls to perform the appropriate edit operations on the application. You won't normally need to worry about this, since TextView provides its own implementation for itself.
There are also a handful of new View APIs, the most important of these being onCreateInputConnection() which creates a new InputConnection for an IME (and fills in an android.view.inputmethod.EditorInfo structure with your input type, IME options, and other data); again, most developers won't need to worry about this, since TextView takes care of it for you.
发表评论
-
android listview
2012-07-13 17:37 929ListView与Button的共存问题解决, 解决在list ... -
演化理解 Android 异步加载图片
2011-11-09 09:55 902LinearLayout 布局,其下放了5个ImageView ... -
android常用颜色
2011-11-07 08:49 1281常用颜色值: 可以完美的颜色比对的网站: http://w ... -
dialog,activity 屏蔽Home键详解
2011-11-03 09:39 0http://www.iteye.com/topic/1116 ... -
android SlidingDrawer example
2011-11-03 09:35 0http://disanji.net/2010/12/16/a ... -
play flash swf file in android with webview
2011-11-03 09:34 0http://androidforums.com/applic ... -
AnimationDrawable 在Dialog中不能动画的原因(转)
2011-11-03 09:33 1303原来在dialog的onCreate onStart调用的时候 ... -
Free Android UI library & component roundup
2011-11-03 09:27 1148http://java.dzone.com/articles/ ... -
Android Fundamentals: Scheduling Recurring Tasks
2011-11-03 09:26 983http://mobile.tutsplus.com/tuto ... -
Android ListView pull up to refresh 改造(转)
2011-11-03 09:25 2098转自: http://dengyin2000.iteye.co ... -
Android中dp和px之间进行转换
2011-11-03 09:02 2265在xml布局文件中,我们既可以设置px,也可以设置dp(或者d ... -
view的setTag() 和 getTag()应用
2011-10-31 12:19 29934View中的setTag(Onbect)表示给View添加一个 ... -
使用getIdentifier()获取资源Id
2011-10-31 12:15 8459使用getIdentifier()获取资源Id int i ... -
ListView的长按菜单___源码分析
2011-10-24 09:28 2594ListView的长按菜单___源码分析 Android的l ... -
让你的Android程序兼容多种分辨率
2011-10-24 09:20 1027http://www.android123.com.cn/an ... -
andr菜单
2011-10-24 09:18 1211Android 菜单 菜单分为两种:系统菜单和上下文菜单。 ... -
Android 长按显示上下文菜单代码
2011-10-24 09:14 5940Android 长按显示上下文 ... -
Android Asynchronous Http Client
2011-10-19 10:27 2907转自: loopj.com/android-async-htt ... -
Android canvas.drawBitmap实现透明效果
2011-09-02 14:22 23439以下是针对,canvas.drawBitmap方法实施透明效 ... -
android资源别名
2011-08-30 14:24 2323详细请参考: http://developer.android ...
相关推荐
Scalability and Efficiency:** Methods for approximating graph convolutions, such as FastGCN and GraphWave, have been developed to make GNNs more scalable and efficient for large-scale graphs. ...
The script is designed to be used in an optimization loop, where the `parameter` input would be updated in each iteration to try and minimize the output of the `fitness` function (i.e., the ...
PATCH-更新系统是坚如磐石,专业,智能,清洁的解决方案,用于管理和分发游戏和应用程序的更新。 您的玩家最终可以毫无痛苦地更新您的游戏,而不必在新版本到来时再次下载整个游戏。这将为他们节省大量带宽和时间!...
ATCH-更新系统是坚如磐石,专业,智能,清洁的解决方案,用于管理和分发游戏和应用程序的更新。 您的玩家最终可以轻松无忧地更新游戏,而无需在新版本到来时再次下载整个游戏。这将为他们节省大量带宽和时间!...
- **Package Management**: The book covers package management tools like APT (Advanced Package Tool) for installing, updating, and removing software. - **Repositories**: Information on adding ...
output them on screen and to printer. TPrinterPreview have all functions and properties as in TPrinter object. You can use TPrinterPreview object similarly of TPrinter except some details. In ...
- and so on.Compatibility-------------SDAC supports SQL Server 7, SQL Server 2000 and MSDE.SDAC requires OLE DB installed on workstation.Note: in current versions of Microsoft Windows, as Windows ...
随着生物技术的不断进步,发酵工程作为生物技术的一个重要分支,在抗生素生产领域发挥了关键作用。本文聚焦于一种含硫的肽类抗生素——诺西肽的发酵生产过程,探讨了其发酵过程的建模及参数更新问题。...
In: inRef - The reference for the object item. Out: None Returns: Returns a reference counter if successful. For errors, returns $FFFFFFFF. -----------------------------------------------------...
- and so on.Compatibility-------------SDAC supports SQL Server 7, SQL Server 2000 and MSDE.SDAC requires OLE DB installed on workstation.Note: in current versions of Microsoft Windows, as Windows ...
React更新状态概述在这段代码中,我们将讨论在React中更新状态并创建一个将根据状态更改其显示内容的组件。目标通过使用this.setState()并传入一个对象来更新React中的状态描述状态更新时会发生什么解释改变状态和...
React:组件安装和卸载 目标 描述在React组件生命周期的更新阶段会发生什么 简要介绍React Ref及其在组件生命周期中的作用 练习使用shouldComponentUpdate和componentDidUpdate 。 概述 在以前的实验室中,我们开发...
Ideal Choice for Updating & Maintaining Legacy Applications Studio for ActiveX supports developing applications in Visual Basic 6.0 and Visual C++ 6.0. We also give you migration utilities for ...
"Updating-Partitioned-Data-Lake-using-Stream-and-Kafka"的主题涵盖了如何利用流处理技术和Apache Kafka来实现实时更新数据湖的过程。在这个场景中,Python扮演了一个重要的角色,因为它提供了丰富的库和工具来...
This option will switch from fast-methods to slower methods, but which take less memory. Use 0 (default) for small projects, use 1 for large projects (if ecc32 runs out of memory). 2)....Added: --el_...
Ideal Choice for Updating & Maintaining Legacy Applications Studio for ActiveX supports developing applications in Visual Basic 6.0 and Visual C++ 6.0. We also give you migration utilities for ...
Ideal Choice for Updating & Maintaining Legacy Applications Studio for ActiveX supports developing applications in Visual Basic 6.0 and Visual C++ 6.0. We also give you migration utilities for ...
Please refer to the Readme.htm file provided with the SMDK for .NET for the latest information on updating your terminal for use with the class libraries and for information on how to deploy your ...
Ideal Choice for Updating & Maintaining Legacy Applications Studio for ActiveX supports developing applications in Visual Basic 6.0 and Visual C++ 6.0. We also give you migration utilities for ...