简体   繁体   中英

How to set ImageView as background for any container?

I'm in need to set an ImageView as a background for a let's say LinearLayout . Is that possible to do so?

I wish you wrote more details about what you require. If this is only about setting an image background, you can use the android:background property of LinearLayout . However, to answer your question directly, a view can be placed behind another using FrameLayout :

<FrameLayout>
    <ImageView/>
    <LinearLayout>
        ...
        ...
    </LinearLayout>
</FrameLayout>

Yes it should be possible. In the layout xml, try wrapping the ImageView inside the LinearLayout. Then in Activity OnCreate function set the xml as content layout.

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