2013-02-11 1 views
0

Я пытаюсь воспроизвести видео, используя код - приведенный ниже код работает отлично
Android - переключение RelativeLayout на вершине просмотра видео

private VideoView mVideoView; 

    mVideoView = (VideoView) findViewById(R.id.vvCarView360); 
    mVideoView.setVideoPath(path); 
    mVideoView.requestFocus(); 
    mVideoView.setOnTouchListener(this); 
    mVideoView.start(); 


rlBottomBar = (RelativeLayout) findViewById(R.id.rlView360BottomBar); 

Теперь при щелчке этот видеоролик я пытаюсь отобразить панель, содержащую некоторые значки. Макет для бара дается
ценам ниже EDIT: ДОБАВЛЕНО ПОЛНОЕ XML

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" > 

<VideoView 
    android:id="@+id/vvCarView360" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:focusable="true" 
    android:focusableInTouchMode="true" /> 

<RelativeLayout 
    android:id="@+id/rlView360BottomBar" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:visibility="invisible" > 

    <ImageView 
     android:id="@+id/ivView360Backbtn" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_centerVertical="true" 
     android:layout_marginLeft="10dp" 
     android:focusable="true" 
     android:focusableInTouchMode="true" /> 

    <ImageView 
     android:id="@+id/ivView360Playbtn" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_centerVertical="true" 
     android:focusable="true" 
     android:focusableInTouchMode="true" /> 

    <ImageView 
     android:id="@+id/ivView360Homebtn" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_centerVertical="true" 
     android:layout_marginRight="10dp" 
     android:focusable="true" 
     android:focusableInTouchMode="true" /> 
</RelativeLayout> 

ontouch слушатель -

@Override 
public boolean onTouch(View v, MotionEvent event) { 

    if (event.getAction() == MotionEvent.ACTION_UP) { 

     switch (v.getId()) { 

     case R.id.vvCarView360: 
      if (mVideoView.isPlaying()) { 

       mVideoView.pause(); 
      } else { 

       mVideoView.start(); 
      } 

      break; 
     } 
    } 
    rlBottomBar.setVisibility(View.VISIBLE); **// This line not getting executed.** 
    return true; 
} 

Я могу видеть видео получать паузу/возобновлено. Это означает, что прослушиватель на ощупь начинает выполняться. Не знаете, почему нижняя панель не отображается. Любая помощь будет высоко оценена.

+1

Здесь вы должны добавить полный код xml для получения ответа. Похоже, что ваш относительный макет перекрывается VideoView? проверьте, что – TNR

+0

@TNR: добавлен полный xml. – Anukool

+0

Добавьте это в свой 'rlView360BottomBar':' android: layout_below = "@ id/vvCarView360" '. –

ответ

0

Вы должны использовать FrameLayout для достижения своих требований. лучше использовать вместо невидимого. Измените свой XML-код, как показано ниже.

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" > 

<VideoView 
    android:id="@+id/vvCarView360" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:focusable="true" 
    android:focusableInTouchMode="true" /> 

<RelativeLayout 
    android:id="@+id/rlView360BottomBar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:visibility="gone" > 

    <ImageView 
     android:id="@+id/ivView360Backbtn" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_centerVertical="true" 
     android:layout_marginLeft="10dp" 
     android:focusable="true" 
     android:focusableInTouchMode="true" /> 

    <ImageView 
     android:id="@+id/ivView360Playbtn" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_centerVertical="true" 
     android:focusable="true" 
     android:focusableInTouchMode="true" /> 

    <ImageView 
     android:id="@+id/ivView360Homebtn" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_centerVertical="true" 
     android:layout_marginRight="10dp" 
     android:focusable="true" 
     android:focusableInTouchMode="true" /> 
</RelativeLayout> 
</FrameLayout> 
Смежные вопросы