[Android development FAQ-8] How to make two buttons half the screen

Source: Internet
Author: User

With the emergence of various large-screen Android machines, the adaptation problem becomes more and more important. Here I will introduce how to make the two buttons each half of the screen, similarly, three, four, or more buttons or other controls can be used to evenly occupy the screen width.

ImplementedCodeAs follows:

<Linearlayout Android: layout_width = "fill_parent" Android: layout_height = "45dp" Android: Orientation = "horizontal" Android: weightsum = "2"> <button Android: layout_width = "wrap_content" Android: layout_height = "fill_parent" Android: layout_weight = "1" Android: Background = "#666"/> <button Android: layout_width = "wrap_content" Android: layout_height = "fill_parent" Android: layout_weight = "1" Android: Background = "#888"/> </linearlayout>

The effect is that the two buttons occupy half the width of the screen.

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.