Fragment

 

本系列文章翻译基于使用Fragment建立动态UI ,其文章已经翻译的很好了,个人只是感觉有些地方翻译的比较生硬和不符合汉语阅读习惯,所以部分照搬过来,如果原作者感觉侵权,可删。

 

Building a Dynamic UI with Fragments

To create a dynamic and multi-pane user interface on Android, you need to encapsulate UI components and activity behaviors into modules that you can swap into and out of your activities. You can create these modules with the Fragment class, which behaves somewhat like a nested activity that can define its own layout and manage its own lifecycle.

  • When a fragment specifies its own layout, it can be configured in different combinations with other fragments inside an activity to modify your layout configuration for different screen sizes (a small screen might show one fragment at a time, but a large screen can show two or more).
  • This class shows you how to create a dynamic user experience with fragments and optimize your app's user experience for devices with different screen sizes, all while continuing to support devices running versions as old as Android 1.6.

Lessons

Creating a Fragment

  Learn how to build a fragment and implement basic behaviors within its callback methods.

Building a Flexible UI

  Learn how to build your app with layouts that provide different fragment configurations for different screens.

Communicating with Other Fragments

  Learn how to set up communication paths from a fragment to the activity and other fragments.

 

Get started

 

 

Dependencies and prerequisites

You should also read

 

用Fragment创建一个灵活的UI

在Android上为了实现一个灵活的、多窗口的交互界面,你可以创建一些Fragment将UI界面和在Activity中的相关操作封装成相应模块,以便在你的activity中可以自由切换。在某些地方,它就像一个嵌套的Activity,比如可以自定义布局和拥有自己的生命周期。

  • 一个fragment定义了自己的布局后,它可以在activity中与其他的fragment生成不同的组合,从而为不同的屏幕尺寸生成不同的布局(一个小的屏幕一次也许只能一个fragment,大的屏幕则可以显示更多)。
  • 本章将展示如何用fragment来创建动态界面,并在不同屏幕尺寸的设备上优化APP的用户体验。即使是运行着android1.6这样老版本的设备,也都能够继续得到支持。

课程目录

  • 创建一个fragment

    学习如何创建一个fragment,以及实现其生命周期内的基本功能。

  • 构建有灵活的UI

    学习在APP内,对不同的屏幕尺寸用fragment构建不同的布局。

开始学习

 

你需要必看的内容

 

你可以选看的内容

完整的Demo示例:FragmentBasics.zip

 

部分翻译来自

使用Fragment建立动态UI

posted @ 2016-02-29 10:53  404map  Views(145)  Comments(0Edit  收藏  举报