Android settings ImageView across two layout blocks

Source: Internet
Author: User

In the project to achieve a picture a at the same time displayed in the middle of two blocks, the height of the general

The middle Orange border part is a piece, the green border part is a piece, their background color one is black one is half black

Then the picture to be displayed across two blocks should be placed in the Green border section

First, it's important to add the orange border and the green border to the root layout .

Android:clipchildren= "false"

Such as:

<linearlayout            android:layout_width= "match_parent"            android:layout_height= "Match_parent"            android: Clipchildren= "false"            android:orientation= "vertical" >

When you set the view in the code, get the height of the a graph, and then set the margintop of the Layoutparam of the A graph to be: half of the negative a graph height

Linearlayout.layoutparams LP = new Linearlayout.layoutparams (LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);        Lp.setmargins (0,-mmenuimageview.getheight ()/2, 0, 0);



Now, this picture shows it's like two zones at the same time.

Android settings ImageView across two layout blocks

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.