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

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

主站蜘蛛池模板: 洛扎县| 宜阳县| 浮梁县| 麻城市| 德阳市| 峡江县| 山西省| 揭西县| 九江县| 隆子县| 教育| 永丰县| 格尔木市| 浦县| 阿勒泰市| 德钦县| 吉安县| 盐边县| 微博| 旌德县| 鹤山市| 静海县| 开封市| 马龙县| 西和县| 金堂县| 崇左市| 元谋县| 龙胜| 翼城县| 克东县| 胶州市| 大冶市| 涟源市| 南澳县| 确山县| 进贤县| 岐山县| 榆林市| 页游| 栾城县|