Reputation: 1159
I need to put a ImageView exactly over a VideoView.
When I use this code in a RelativLayout
<VideoView
android:id="@+id/videoView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true" />
the VideoView is shown on the top, the ImageView is centered vertically. What can be done to also center the ImageView, that both Views are at the same position and have the same size, when a video and a picture with the same resolution are displayed?
Upvotes: 3
Views: 4315
Reputation: 276
Place first videoview then imageview in framelayout, if you are still facing problem there might be..
videoView.setZOrderOnTop(true) set by you, so make it false or remove it.
Upvotes: 1
Reputation: 31
Your answer seems to be here http://developer.android.com/guide/topics/ui/layout/relative.html you need to use the ids of the elements you are trying align with.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp" >
<EditText
android:id="@+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/reminder" />
<Spinner
android:id="@+id/dates"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_below="@id/name"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/times" />
<Spinner
android:id="@id/times"
android:layout_width="96dp"
android:layout_height="wrap_content"
android:layout_below="@id/name"
android:layout_alignParentRight="true" />
<Button
android:layout_width="96dp"
android:layout_height="wrap_content"
android:layout_below="@id/times"
android:layout_alignParentRight="true"
android:text="@string/done" />
</RelativeLayout>
Your example should be something like this ,I have not been able to test it yet .
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true" />
<VideoView
android:id="@+id/videoView1"
android:layout_width="wrap_content"
android:layout_below="@id/imageView1"
android:layout_alignParentLeft="true" />
Upvotes: 0
Reputation: 1159
I just replaced my RelativLayout with an FrameLayout and everything did well.
Upvotes: 3