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

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.)

主站蜘蛛池模板: 元阳县| 独山县| 万州区| 凉城县| 周宁县| 延安市| 博野县| 梨树县| 祁连县| 萨嘎县| 甘德县| 绵阳市| 怀宁县| 吉水县| 黑河市| 平山县| 沙洋县| 漠河县| 岫岩| 定结县| 周口市| 呼伦贝尔市| 多伦县| 内江市| 满洲里市| 天等县| 海兴县| 永嘉县| 开阳县| 外汇| 宜宾市| 成安县| 府谷县| 泽州县| 九江市| 信丰县| 东安县| 新源县| 肥东县| 闽侯县| 津市市|