New Android journey (11) Insert a new view into the existing page

Source: Internet
Author: User

In some specific situations, you cannot use static methods to define the view used in the page. For example, a custom graph is an independent view. To insert it into a page as a part, you need the following methods:

Linearlayout L = new linearlayout (this); // L indicates the current page layout.

L. addview (myview); // Add a new view
L. setpadding (20,390, 20, 40); // set the position
Linearlayout. layoutparams P = new linearlayout. layoutparams (linearlayout. layoutparams. wrap_content, linearlayout. layoutparams. wrap_content );
L. setlayoutparams (p); // parameters of the new view
This. addcontentview (L, P); // Add a new view

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.