Android-app widget (5)

Source: Internet
Author: User
Tags home screen

Dimension adjustment Guide

When a widget is locked, the android framework ignores the minwidth, minheight, minresizewidth, and minresizeheight attribute fields. If the widget can be placed on the home screen at the same time, these attribute fields are still required because they are used on the home screen, but are ignored for screen lock.

The width of the screen lock widget is always filled in the provided space, and its height has the following options:

1. If the widget is not marked with its vertical size adjustable (Android: resizemode = "vertical"), its height will always be in "small" Mode:

In the phone portrait mode, "small" is defined as showing the remaining space after unlocking the UI;

"Small" is the basic setting for each device in tablet and horizontal phones.

2. If the widget is marked with a vertical adjustable size, the height of the widget will use the "small" Mode on the portrait phone that shows the UI to be unlocked. In all other cases, the widget adjusts the height to fill the available height.

Use an app widget with a set

Android3.0 and later introduced app widgets with collections. These types of apps
The widget uses remoteviewservice to display the data set returned by remote data, such as data from contentprovider. The data provided by remoteviewsservice is displayed in one of the following types of views. We call these views "set views ":

Listview

Displays the view of data in a vertical scrolling list. For example, Gmail app
Widget

Gridview

Display the data view in a two-dimensional rolling grid. For example, the bookmarks app
Widget

Stackview

A View of stacked cards (a bit like a network of relationships) allows you to extract cards down or up to view the previous or next cards separately. For example, apps included in YouTube and books
Widget.

Adapterviewfilpper

An adapter view that supports Simple viewanimator. It can generate animations between two or more views. Only one subview is displayed at a time.

In the preceding view, the dataset returned by the remote data is displayed. This means that they need to use an adapter to bind data to the user interface. The adapter binds each data item in the dataset to each view object. Because these set views are supported by the adapter, the android framework must contain additional architectures to support
Widgets. In the app widget content, the adapter will be replaced by remoteviewsfactory, which simply encapsulates the adapter interface. When a special project in the collection is requested, remoteviewsfactory will create a collection and return a remoteviews object. In order
The widget contains a set of views. You must implement the remoteviewsservice and remoteviewsfactory interfaces.

Remoteviewsservice is a service that allows remote adapters to request remoteviews objects.

Remoteviewsfactory is an adapter interface between the view and view data in the set. The following code is from stackview.
Widget example, which is a sample code for implementing services and interfaces:

Publicclassstackwidgetserviceextendsremoteviewsservice {
@ Override
Public remoteviewsfactoryongetviewfactory (intent ){
Return new stackremoteviewsfactory (this. getapplicationcontext (), intent );
}
}

Class stackremoteviewsfactory implements remoteviewsservice. remoteviewsfactory {

//... Include adapter-like methods here. See the stackviewwidget sample.

}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.