About Setlayoutparams Error

Source: Internet
Author: User

has two possible causes
 1. The internal view does not use its parent's layoutparams
when inheriting Baseadapter, when returning to view with GetView, the code controls the layout, Need to use the View.setlayoutparams, but the error, the report is a type conversion errors, after research, found that the viewgroup.layoutparams can not be used here and must use the corresponding parent view of the Layoutparams type. For example, if a view is contained by LinearLayout, the view's setlayoutparams parameter type must be Linearlayout.layoutparams. The reason for this is that linearlayout (or other layouts that inherit from ViewGroup, such as Relativelayout), LinearLayout get the layoutparams of the child view when the layout is recursive. and cast into Linearlayout.layoutparams.
   2. Outermost, cannot setlayoutparams
because it has no parent. The API explains: These supply parameters to the parent of this view specifying how it should is arranged. Indicates that the parameters set here are provided to the parent.
public void Setlayoutparams (viewgroup.layoutparams params)
Since:api Level 1
Set the layout parameters Associ Ated with this view. These supply parameters to the parent of this view specifying how it should is arranged. There is many subclasses of viewgroup.layoutparams, and these correspond to the different subclasses of ViewGroup that AR E responsible for arranging their children.

About Setlayoutparams Error

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.