UI Overview
来源:互联网 发布:如何培养英语思维 知乎 编辑:程序博客网 时间:2024/06/10 17:00
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).
Android 中所有的用户界面都是通过View 和ViewGroup对象来创建的,View 对象是显示在屏幕上用来和用户进行交互,而ViewGroup是用来存放View对象和规划页面布局的。同时系统提供了很多有关View 和ViewGroup的子类来供我们使用。
User Interface Layout
The user interface for each component of your app is defined using a hierarchy of View and ViewGroup objects, as shown in figure 1. Each view group is an invisible container that organizes child views, while the child views may be input controls or other widgets that draw some part of the UI. This hierarchy tree can be as simple or complex as you need it to be (but simplicity is best for performance).
Figure 1. Illustration of a view hierarchy, which defines a UI layout.
To declare your layout, you can instantiate View objects in code and start building a tree, but the easiest and most effective way to define your layout is with an XML file. XML offers a human-readable structure for the layout, similar to HTML.
The name of an XML element for a view is respective to the Android class it represents. So a element creates a TextView widget in your UI, and a element creates a LinearLayout view group.
For example, a simple vertical layout with a text view and a button looks like this:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="I am a TextView" /> <Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="I am a Button" /></LinearLayout>
When you load a layout resource in your app, Android initializes each node of the layout into a runtime object you can use to define additional behaviors, query the object state, or modify the layout.
For a complete guide to creating a UI layout, see XML Layouts.
User Interface Components
You don’t have to build all of your UI using View and ViewGroup objects. Android provides several app components that offer a standard UI layout for which you simply need to define the content. These UI components each have a unique set of APIs that are described in their respective documents, such as Action Bar, Dialogs, and Status Notifications.
我们并不都需要使用View 或ViewGroup对象来初始化组件,例如系统给我们定义好了布局对象 ,我们只需要向其中添加组件即可。
- UI overview
- UI Overview
- UI Overview
- UI Overview
- UI Overview
- UI Overview
- 学习“UI Overview”
- UI Overview//用户界面概述
- 用户界面概述--UI OVERVIEW
- 【Unity3D】【UGUI】UI Overview
- UI Overview(用户界面综述)
- UI Overview——UI概述
- Overview
- Overview
- Overview
- Overview
- overview-overview
- 拥有所有你需要去速建HTML5网站应用的Kendo UI--Overview
- Tomcat开发Servlet之NoClassFoundException解决方法
- php中的关于xml的使用(SEO)
- Zookeeper节点类型
- 新浪微博Redis应用经验--总结自InfoQ
- adb无法识别魅族note2
- UI Overview
- hdu 5348 MZL's endless loop
- java大数用法
- [LeetCode]228.Summary Ranges
- 操作系统面试题转载
- errorPage跳转问题
- 如何准确计算Java对象的大小
- c# -- 对象销毁和垃圾回收
- linux MySQL相关问题