简体   繁体   中英

View on top of another using Android's FrameLayout

I'm trying to place a view on top of another with frame layout. For a view with fixed size it is okay. The issue is that if the view has a list I can't define the overlay view height. If I set the overlay height as "wrap content" it will take all the screen:

在此处输入图片说明

If i set the height in the xml it will not cover the whole view when views are added to the radioButtonAnswersLinearLayout:

Code:

在此处输入图片说明

You're constraining the overlay view to the parent's top, bottom, start and end, so it will expand the overlay to cover the entire view. Remove the bottom constraint and set the height, should work then.

Edit: Re-read the question. If you want to use wrap_content , just remove the bottom constraint to parent from the overlay view, and set the height to wrap_content.

Edit 2: Change your overlay to a FrameLayout, instead of a view, and set the height to match_parent :

<FrameLayout
    android:id="@+id/overlay"
    android:layout_height="match_parent" 
    ...
    />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM