[android] Overlapping Views in Android

Is it possible to have overlapping views in Android? I would like to have an ImageView with a transparent png in the front and another view in the background.

edit:

This is what I have at the moment, the problem is that the image in the imageView is not transparent, the parts that should be transparent are just black.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/gallerylayout"
>
<Gallery android:id="@+id/overview"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    />

 <ImageView android:id="@+id/navigmaske"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:src="@drawable/navigmask"
    /> 

</RelativeLayout>

edit:

I got it to work, it was a theme file from another programmer on the team. Just changed this

<item name="android:background">#FF000000</item>

to this

<item name="android:background">#00000000</item>

This question is related to android view android-relativelayout

The answer is


The simples way arround is to put -40dp margin at the buttom of the top imageview


Visible gallery changes visibility which is how you get the gallery over other view overlap. the Home sample app has some good examples of this technique.


Also, take a look at FrameLayout, that's how the Camera's Gallery application implements the Zoom buttons overlay.


Yes, that is possible. The challenge, however, is to do their layout properly. The easiest way to do it would be to have an AbsoluteLayout and then put the two images where you want them to be. You don't need to do anything special for the transparent png except having it added later to the layout.


If you want to add you custom Overlay screen on Layout, you can create a Custom Linear Layout and get control of drawing and key events. You can my tutorial- Overlay on Android Layout- http://prasanta-paul.blogspot.com/2010/08/overlay-on-android-layout.html


Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to view

Empty brackets '[]' appearing when using .where SwiftUI - How do I change the background color of a View? Drop view if exists Difference between View and ViewGroup in Android How to make a view with rounded corners? How to remove all subviews of a view in Swift? How to get a view table query (code) in SQL Server 2008 Management Studio how to add button click event in android studio How to make CREATE OR REPLACE VIEW work in SQL Server? Android findViewById() in Custom View

Examples related to android-relativelayout

How to switch from the default ConstraintLayout to RelativeLayout in Android Studio Differences between ConstraintLayout and RelativeLayout Moving from one activity to another Activity in Android RelativeLayout center vertical Android Relative Layout Align Center Android: show/hide a view using an animation How to set RelativeLayout layout params in code not in xml? How to create a RelativeLayout programmatically with two buttons one on top of the other? Percentage width in a RelativeLayout What are the differences between LinearLayout, RelativeLayout, and AbsoluteLayout?