Bob Koutsky
2011-05-26 23:42:24 UTC
Hello,
I'm trying to create an activity based on LinearView, with some
graphics at the top, VideoView in the middle and more graphics and
controls at the bottom. I'd like to have MediaController positioned
over VideoView, so it does not obscure stuff at the bottom of the
screen. I tried calling MediaController.setAnchorView with almost all
possible parameters - at first I used the VideoView, then I embedded
the ViewView in extra layout and used that as anchorview, without
success. Usually, the MediaController is displayed at the bottom of
the screen, the best I was able to get was that it appeared directly
below the VideoView (when I enclosed VideoView in extra layout). The
MediaController was at the bottom of the screen even if I used some an
ImageView at the top of the screen as an anchor. The docs say
"Specifically, the controls will float above the view specified with
setAnchorView()." but to me it seems that setAnchorView is mostly
ignored.
What am I doing wrong? Is it even possible to place MediaController
over VideoView (so that their bottom edges are aligned)?
relevant source & layout is below.
thanks for any advice,
Bob
excerpt from VideoActivity.java:
public void onCreate(Bundle savedInstanceState) {
Dbg.d("WPLAY", "onCreate");
super.onCreate(savedInstanceState);
setContentView(R.layout.video_player);
Intent intent = getIntent();
player = (VideoView) findViewById(R.id.player);
controller = new MediaController(this);
controller.setAnchorView(player);
player.setMediaController(controller);
String url = "[video url here]";
Dbg.d("WPLAY", "playing " + url);
player.setVideoURI(Uri.parse(url));
player.requestFocus();
player.start();
}
layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
<ImageView
android:src="@drawable/logo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/word"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:textSize="20sp"
android:singleLine="true"
android:gravity="center_horizontal"
android:padding="4dip"
android:text="text"
/>
<VideoView
android:id="@+id/player"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
/>
<TableLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
<TableRow>
<ImageView android:id="@+id/en" android:src="@drawable/gb"
android:layout_height="48dip" android:layout_width="48dip"/>
<ImageView android:id="@+id/sv" android:src="@drawable/se"
android:layout_height="48dip" android:layout_width="48dip"/>/>
</TableRow>
<TableRow>
<ImageView android:id="@+id/de" android:src="@drawable/de"
android:layout_height="48dip" android:layout_width="48dip"/>/>
</TableRow>
</TableLayout>
</LinearLayout>
I'm trying to create an activity based on LinearView, with some
graphics at the top, VideoView in the middle and more graphics and
controls at the bottom. I'd like to have MediaController positioned
over VideoView, so it does not obscure stuff at the bottom of the
screen. I tried calling MediaController.setAnchorView with almost all
possible parameters - at first I used the VideoView, then I embedded
the ViewView in extra layout and used that as anchorview, without
success. Usually, the MediaController is displayed at the bottom of
the screen, the best I was able to get was that it appeared directly
below the VideoView (when I enclosed VideoView in extra layout). The
MediaController was at the bottom of the screen even if I used some an
ImageView at the top of the screen as an anchor. The docs say
"Specifically, the controls will float above the view specified with
setAnchorView()." but to me it seems that setAnchorView is mostly
ignored.
What am I doing wrong? Is it even possible to place MediaController
over VideoView (so that their bottom edges are aligned)?
relevant source & layout is below.
thanks for any advice,
Bob
excerpt from VideoActivity.java:
public void onCreate(Bundle savedInstanceState) {
Dbg.d("WPLAY", "onCreate");
super.onCreate(savedInstanceState);
setContentView(R.layout.video_player);
Intent intent = getIntent();
player = (VideoView) findViewById(R.id.player);
controller = new MediaController(this);
controller.setAnchorView(player);
player.setMediaController(controller);
String url = "[video url here]";
Dbg.d("WPLAY", "playing " + url);
player.setVideoURI(Uri.parse(url));
player.requestFocus();
player.start();
}
layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
<ImageView
android:src="@drawable/logo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/word"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:textSize="20sp"
android:singleLine="true"
android:gravity="center_horizontal"
android:padding="4dip"
android:text="text"
/>
<VideoView
android:id="@+id/player"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
/>
<TableLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
<TableRow>
<ImageView android:id="@+id/en" android:src="@drawable/gb"
android:layout_height="48dip" android:layout_width="48dip"/>
<ImageView android:id="@+id/sv" android:src="@drawable/se"
android:layout_height="48dip" android:layout_width="48dip"/>/>
</TableRow>
<TableRow>
<ImageView android:id="@+id/de" android:src="@drawable/de"
android:layout_height="48dip" android:layout_width="48dip"/>/>
</TableRow>
</TableLayout>
</LinearLayout>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-***@googlegroups.com
To unsubscribe from this group, send email to
android-developers+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-***@googlegroups.com
To unsubscribe from this group, send email to
android-developers+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en