Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8183815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:17:03+00:00 2026-06-07T01:17:03+00:00

In Android, I know how to overlay two images and to animate them. The

  • 0

In Android, I know how to overlay two images and to animate them. The question is how to overlay the second image at a specific location over the first image.

As an example, the first image is the image of an appliance with a power switch, the second image is the power LED that will glow when animated.

I would like to know how I can specify the location of the power LED in the overlay so that it covers the power switch.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T01:17:04+00:00Added an answer on June 7, 2026 at 1:17 am

    One thing you can do is to put both images inside a FrameLayout, with the width/height on both set to wrap_content. The last one you add to the FrameLayout will be on top. Then you can position the two images independently in one of several ways:

    1) You could set the layout_gravity of both items to top|left, then set layout_marginTop and layout_marginLeft to position the two images relative to the upper left corner of the FrameLayout.

    2) If you want to, say center image B on top of image A, you could set image A to layout_gravity top|left, layout_marginLeft 0, layout_marginTop 0, then set layout_gravity on image B to center. This approach is a bit more robust with respect to running on various devices. You can even use the margins to offset image B with respect to its centered position.

    You should get the idea at this point. You can combine layout_gravity along with margins to position the images as you need.

    Some caveats:

    1) This is not a very efficient way to go about things. If it’s just two images in a larger layout, no big deal. But rendering performance will suffer if you do this technique many times in a layout. If that’s the case, you should consider creating a custom view instead.

    2) You need to explicitly set the layout_gravity on an item contained within a FrameLayout. Otherwise FrameLayout will ignore the layout_marginTop and layout_marginLeft attributes on your child views.

    Finally, you can do this same trick with RelativeLayout, using its attributes to position the images in relation to one another. Like FrameLayout, the last view added to the layout shows up on top of the others.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The solution #2 (dynamic) in this question/answer post: overlay two images in android to
Although I know image resolutions and support them on the android is a fairly
I know how to use Overlay in Android applications i used it plenty of
I am new iOS development but I know android at eclipse. For example I
Is it possible to overlay a Button over a Label in Swing? For example,
just curious to know android Graphical components (View) have their own specific renderer or
I had some experience of android but know almost nothing of GCC Makefile. Here
I know that Android has a JSON parser baked in but I was wondering
An Android mobile actually does know quite well where it is - but is
i know how to proguard android project,but at present i use android do a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.