Reputation: 13329
Im very new to android development..
It looks like the ImageView is ontop of the VideoView, and therefore the VideoView does not display. Is this true? And do I need to change the order of the views when I want to videoview to show? and again when the imageView must display an image?
I loop through a list of images and videos and show the images for x seconds, then move on to the next element, could be a video or image.
This is my layout:
<LinearLayout
android:id="@+id/LinearLayout01"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:orientation="horizontal">
<ImageView
android:contentDescription="@raw/image"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:scaleType="fitCenter"
android:id="@+id/imageView" />
<VideoView
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:scaleType="fitCenter"
android:id="@+id/videoView" />
<!-- <SurfaceView
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:id="@+id/surface" /> -->
</LinearLayout>
Upvotes: 0
Views: 584
Reputation: 2348
as the imageView and the videoView are in the same LinearLayout, they display next to each other; not on another layer.
I guess the VideoView is not showing as you don't link any content to it. At least that is what my eclipse is displaying.
Upvotes: 0
Reputation: 22342
It's not Z-ordering that's your problem. You have a LinearLayout
with two views. It's set to horizontal
, so it wants to draw them next to each other. However, you are using fill_parent
for the width, so the first view takes up all the space, and the next view is drawn off the screen(to the right).
A simple solution would be to flip the visibility
states of the views when you want one or the other shown. There are more elegant ways to do this, I'm sure, but that's a simple one.
Upvotes: 2