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

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

主站蜘蛛池模板: 咸丰县| 镇赉县| 徐闻县| 随州市| 丰镇市| 万宁市| 南汇区| 麻江县| 象山县| 泸水县| 闽清县| 大新县| 晋州市| 丹阳市| 双牌县| 札达县| 沛县| 旌德县| 沙坪坝区| 杭锦旗| 金溪县| 临武县| 商水县| 渝中区| 德江县| 西昌市| 涪陵区| 庆安县| 玉环县| 娱乐| 淳化县| 桐梓县| 宁明县| 诏安县| 安泽县| 灵寿县| 新田县| 晋江市| 手游| 济南市| 通海县|