官术网_书友最值得收藏!

Introduction

The term widgets can refer to several different concepts in Android. When most people talk about widgets, they are referring to app widgets, which are typically seen on the home screen. App widgets are like mini applications by themselves as they usually provide a subset of functionality, based on their main application. (Usually, most app widgets are installed along with an application, but that is not a requirement. They can be standalone apps in a widget format.) A common app widget example is a weather application that offers several different app widgets for the home screen. Chapter 5, Exploring Fragments, AppWidgets, and the System UI, will discuss home screen app widgets and provide recipes to create your own.

When developing for Android, the term widgets generally refers to specialized Views placed in the layout files, such as a Button, TextView, CheckBox, and so on. In this chapter, we will focus on widgets for app development.

To see the list of widgets provided in the Android SDK, open a layout file in Android Studio, and click on the Design tab. Along the left side of the Design view, you will see the Widget section below the Layout section, as in the following screenshot:

As you can see from the list, the Android SDK provides many useful widgets—from a simple TextView, Button, or Checkbox to the much more complex widgets such as the Clock, DatePicker, and Calendar. As useful as the built-in widgets are, it's also very easy to expand on what's provided in the SDK. We can extend an existing widget to customize its functionality, or we can create our own widget from scratch by extending the base View class. (We will provide an example of this in the Creating a custom component recipe later.)

The visual look of widgets can also be customized. These settings can be used to create styles, which in turn can be used to create themes. Just like with other development environments, creating a theme offers the benefit of easily changing the appearance throughout our entire application with minimal effort. Lastly, the Android SDK also provides many built-in themes and variations, such as the Holo theme from Android 3/4 and the Material theme from Android 5. (Android 6.0 did not release a new theme.)

主站蜘蛛池模板: 漳平市| 古丈县| 云龙县| 奎屯市| 来凤县| 黄石市| 灌阳县| 云浮市| 全南县| 光泽县| 高雄市| 泽州县| 哈尔滨市| 湖口县| 墨玉县| 巴青县| 嘉鱼县| 和龙市| 板桥市| 嘉荫县| 西畴县| 都昌县| 遵义县| 桃园县| 盘山县| 石柱| 若羌县| 周口市| 昌吉市| 大洼县| 都昌县| 邓州市| 长寿区| 精河县| 安西县| 新民市| 上饶县| 班戈县| 织金县| 尼勒克县| 五大连池市|