【发布时间】:2011-08-06 14:42:21
【问题描述】:
我的活动布局如下所示。基本上我在左侧有一个列表视图菜单和两个视频视图,我根据用户单击的菜单项在它们之间切换。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_system_status"
android:title="@string/system_status"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="4">
<ListView
android:id="@+id/list_video_feed"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</ListView>
</LinearLayout>
<LinearLayout
android:id="@+id/linear_layout_live_video"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="1">
<VideoView
android:id="@+id/video_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/linear_layout_video_gallery"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="1">
<Gallery
android:id="@+id/gallery"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<VideoView
android:id="@+id/archived_video_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
</LinearLayout>
在我的代码中,如果我想从没有画廊的视图中播放视频,我会隐藏另一个。
linearLayoutVideoGallery.setVisibility(GONE);
linearLayoutLiveVideo.setVisibility(VISIBLE);
playVideo();
问题是archived_video_view 保持在顶部,只有画廊隐藏。有小费吗?如果您需要任何其他信息,请告诉我。谢谢!
编辑:这是我在 onCreate() 中选择菜单项的 if 语句。希望这会有所帮助。当我点击 position==1 然后 postion==2 时,画廊消失了,但archived_video_view 仍然在那里暂停,所以我只能看到画廊曾经所在的video_view 的顶部。
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
if (position==1) { //video gallery list item has been pressed
vvLive.stopPlayback();
linearLayoutLiveVideo.setVisibility(GONE);
linearLayoutVideoGallery.setVisibility(VISIBLE);
playArchivedVideo();
}
else if (position == 2) { //live video list item has been pressed
vvArchive.stopPlayback();
linearLayoutVideoGallery.setVisibility(GONE);
linearLayoutLiveVideo.setVisibility(VISIBLE);
playLiveVideo();
}
}
});
【问题讨论】:
-
您确定您使用正确的 id 来获取您的 linearLayoutVideoGallery 和 linearLayoutLiveVideo 视图吗?
-
是的。当我单击视频库然后单击实时视频时,顶部的水平画廊被隐藏,我只看到实时视频播放的那一小部分,因为存档的视频仍在前景中。我在上面的 switch 语句中添加了一些额外的代码。谢谢。
标签: android visibility android-linearlayout android-videoview