Android dynamically changes the component size. android Components

Source: Internet
Author: User

Android dynamically changes the component size. android Components

Note: to change the component, set it to warp_content in XML. For example:

If you want to change the width of a button, set its layout_width to wrap_content in xml.


In the code, you can dynamically set the width by setting LayoutParams.

ImageView pictureView = (ImageView) convertView. findViewById (R. id. picture_view); ViewGroup. layoutParams layoutParams = holder. picture. getLayoutParams (); layoutParams. width = 1024; layoutParams. height = 768; pictureView. setLayoutParams (layoutParams );

Android interview questions Video Explanation



Dynamically set the widget size? Android

For example, a button is in a LinearLayout.
So
B. setLayoutParams (new LinearLayout. LayoutParams (10, 10 ));
The unit of d is pixel.

How does the android control dynamically change the location and size as the screen size of the mobile phone varies?

Weight is the proportion. All weight is the total size.
 

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.