New Android journey (10) nested layout

Source: Internet
Author: User

If you want to put four buttons on the interface, they exist in the form of 2*2, but there is no way to implement them quickly. After a try, we can use the nested method. One linearlayout is nested with two linearlayout. The outer linearlayout uses the vertical layout, while the internal layout uses the horizontal layout.

XML file:

<? XML version = "1.0" encoding = "UTF-8"?>
<Linearlayout xmlns: Android = "http://schemas.android.com/apk/res/android"
Android: Orientation = "vertical"
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent"
Android: Background = "@ drawable/bk0">
<Linearlayout xmlns: Android = "http://schemas.android.com/apk/res/android"
Android: Orientation = "horizontal"
Android: layout_width = "fill_parent"
Android: layout_height = "180px"
Android: layout_marginleft = "60px" Android: layout_margintop = "70px"
>
<Button Android: Background = "@ drawable/btn01"
Android: text = "" Android: Id = "@ + ID/button1"
Android: layout_width = "wrap_content" Android: layout_height = "wrap_content"
>
</Button>
<Button Android: Background = "@ drawable/btn02"
Android: text = "" Android: Id = "@ + ID/button2"
Android: layout_width = "wrap_content" Android: layout_height = "wrap_content"
>
</Button>
</Linearlayout>
<Linearlayout xmlns: Android = "http://schemas.android.com/apk/res/android"
Android: Orientation = "horizontal"
Android: layout_width = "fill_parent"
Android: layout_height = "180px"
Android: layout_marginleft = "60px" Android: layout_margintop = "0px"
>
<Button Android: Background = "@ drawable/btn03"
Android: text = "" Android: Id = "@ + ID/button3"
Android: layout_width = "wrap_content" Android: layout_height = "wrap_content"
>
</Button>
<Button Android: Background = "@ drawable/btn04"
Android: text = "" Android: Id = "@ + ID/button4"
Android: layout_width = "wrap_content" Android: layout_height = "wrap_content"
>
</Button>
</Linearlayout>
</Linearlayout>

Effect:

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.