Android Concise development Tutorial VI: User interface design

Source: Internet
Author: User

Activity is the basic component of the Android application user interface. The activity itself does not, however, provide a user interface (Interface). From the program structure level, an Android application is an instance of class Android.app.Application, application can contain multiple android.app.Activity instances. Each activity takes a window class that does not provide much functionality on the Android platform and can be used primarily to control the title bar (the top of the screen). For example, you can use the following code to set the UI Full-screen display:

Requestwindowfeature (window.feature_no_title);
       
GetWindow (). SetFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN,
       
WindowManager.LayoutParams.FLAG_ fullscreen);

Activty default is no user interface, if you want to display the user interface, you can call Setcontentview () to set the Contentview of the activity. Conentview describes the specific UI components, such as text boxes, labels, list boxes, picture frames.

The Android user interface actually refers to the Contentview design. "View" at the beginning will cause misunderstanding, in other platforms "view" generally refers to the concept of similar form. On the Android platform view is the UI component, and the equivalent of the other platform's component,viewgroup is equivalent to the container of the other platforms, as shown in the following illustration:

With this correspondence it is easy to use your existing user interface design knowledge in the Android user interface design.

In addition to the Android user interface design a recommended method is to use XML to describe the UI, which is not the first of the Android platform, Java ME polish,wpf,silverlight, and so on, using XML to describe the UI, The benefit of using XML is to separate the user interface from the program logic, so that the user interface changes do not affect the program logic, the change of program logic can not affect the user interface, in fact, the design of the MVC pattern is adopted. The activity is the controller,activity in MVC Contentview is the view in MVC. If you do not want to use XML to describe the UI, you can also use code to create the UI, but this approach is both cumbersome and adds to the coupling between modules.

After understanding the Android view and ViewGroup, the specific design user interface is not complex, and generally viewgroup defines the layout of its child view layout, which is the other View (text box, tags such as controls or other viewgroup are arranged in the user interface position. As shown in the figure above, this hierarchy can be nested. By nesting, you can define any user interface.

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.