How to define the Android View class description

Source: Internet
Author: User

This article explains the problems that most users want to know about the Android View class. In fact, this Android View class is a superclass in Android, it is usually defined as the XML content View of View and Android during programming.

The Android View class is a superclass of Android, which contains almost all screen types. But there are some differences between them. Each view has a canvas for painting. This canvas can be used for any extension. For convenience, this article only involves two main View types: defining the View and Android XML content View.

In the above Code, the "Hello World" XML View is used, which starts in a very natural way. If you want to view the new Android project. You will find a file named main. xml. In this file, a simple XML file is used to describe the layout of a screen. The content of this simple xml file is as follows:

 
 
  1. <?xml version="1.0" encoding="utf-8"?> <RelativeLayout
  2. xmlns:android="http://schemas.android.com/apk/res/android" 
  3. android:orientation="vertical" android:layout_width="fill_parent"
  4.  android:layout_height="fill_parent"  > 
  5. <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" 
  6. android:layout_centerHorizontal="true" 
  7. android:text="Press the center key to locate yourself"  /> </RelativeLayout>  

The features of the above content seem very obvious. This special file defines a related layout, which means that the relationship between an element and another element or the relationship between their parent element is described. For a view, there are some layout methods.

However, this article only focuses on the above xml files. RealtiveLayout contains a text box that fills the entire screen, that is, our LocateMe activity ). This LocateMe activity is full screen by default. Therefore, the text box inherits this attribute and will be displayed in the upper left corner of the screen. In addition, you must set

 
 
  1. <?xml version="1.0" encoding="utf-8"?> <RelativeLayout
  2. xmlns:android="http://schemas.android.com/apk/res/android" 
  3. android:orientation="vertical" android:layout_width="fill_parent"
  4.  android:layout_height="fill_parent"  > 
  5. <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" 
  6. android:layout_centerHorizontal="true" 
  7. android:text="Press the center key to locate yourself"  /> </RelativeLayout>  

Views can also be nested, but different from j2s, we can use custom views together with Widgets released by the Android team. In j2s, developers are forced to select the GameCanvas and j2s application canvases. This means that if we want a customized effect, we have to redesign all our widgets on GameCanvas. Android can be used in combination with other view types.

The Android View class also includes a widget library, which includes the scroll bar, Text object, progress bar, and many other controls. These standard widgets can be reloaded or customized according to our habits. Now let's go to our example.

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.