2017-09-26 3 views
0

저는 비디오를 비교하기 위해 앱에서 일하고 있는데,이 유스 케이스가 있습니다. 이게 보이는 모양입니다. Two Videos view너비의 절반을 숨기는 두 개의 비디오를 나란히 놓는 방법?

상대 레이아웃을 확장하고 그 안에 비디오보기를 넣는 사용자 지정보기로 시도했지만이 결과를 얻을 수 없습니다.

비디오 너비는 화면 너비와 같아야합니다. 누군가 비디오를 가볍게 두드리면 완전히 보일 때까지 번역해야하기 때문입니다. 왼쪽 비디오는 너비 스크린의 절반만큼 왼쪽으로 변환되어야하고 동일한 로직이 오른쪽 비디오에 적용되어야한다고 생각합니다.

+0

Pls는 몇 가지 코드를 게시 할 수 있습니다. – iMDroid

+0

당신이 얻고있는 결과의 세부 사항들. – iMDroid

+0

가중치 합을 사용하십시오. –

답변

0

난 당신이 UR 비디오

activty_main.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="horizontal" 
     android:weightSum="2"> 

     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="@color/colorAccent"> 

     </LinearLayout> 

     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="@color/colorPrimaryDark"> 

     </LinearLayout> 

    </LinearLayout> 

    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     android:src="@mipmap/ic_launcher" /> 


</RelativeLayout> 

enter image description here

재생에 사용하여 VideoView를 지켜 보면서를 배치 할 수있는 있는 LinearLayout 내에서 this를 시도 할 수 있습니다 하나 개의 샘플을 걸었습니다
0

가장 쉬운 방법은 가로 방향의 가로 레이아웃을 만들어 내부에 넣는 것입니다 두 개의 뷰 (SurfaceView 또는 TextureView 또는 GlSurfaceView). 볼

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:baselineAligned="false" 
android:orientation="horizontal" > 

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="horizontal" 
    android:layout_weight="1" 
    android:layout_marginRight="8dp" > 

    <TextureView 
     android:id="@+id/double1_texture_view" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 
</LinearLayout> 

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="horizontal" 
    android:layout_weight="1" > 

    <TextureView 
     android:id="@+id/double2_texture_view" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 
</LinearLayout> 

가장 좋은 샘플이 Grafika입니다 : 그리고처럼 될 것이보기 1. 동일한 무게를 제공합니다. 그러나 의 비디오를 비교하려는 경우과 같이 비디오 중 하나를 잘라야한다는 것을 잊지 마십시오. 한 비디오의 왼쪽과 다른 비디오의 왼쪽을 비교해야하기 때문에. 종횡비를 잊지 마세요. 내가 화면의 폭을 요청 활동의에서 onCreate에,

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

<com.google.android.exoplayer2.ui.SimpleExoPlayerView 
    android:id="@+id/right_video" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="@color/colorAccent" /> 

<com.google.android.exoplayer2.ui.SimpleExoPlayerView 
    android:id="@+id/left_video" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="@color/colorPrimary" /> 

</FrameLayout> 

프로그래밍을하고 X 축에서 번역합니다

+0

그러나이 경우 누군가가 비디오를 들었을 때 비디오의 번역을 어떻게 처리합니까? –

+0

올바른 레이아웃으로는이 작업을 수행 할 수 없습니다. 번역 및 자르기를하려면 GL 명령과 GlSurfaceView를 사용해야합니다. – Sheikh

+0

Object Animator를 사용하여 애니메이션을 만들 수 있습니다. https://developer.android.com/guide/topics/graphics/prop-animation.html#views –

0

나는 다음과 같은 레이아웃으로 그렇게 할 수 있습니다.

Point screenDimens = ViewUtils.getScreenDimensions(this); 
    int videoSize = screenDimens.x; 
    FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) leftVideo.getLayoutParams(); 
    params.width = videoSize; 
    params.height = videoSize; 
    leftVideo.setLayoutParams(params); 
    rigthVideo.setLayoutParams(params); 
    leftVideo.setTranslationX(-videoSize/2); 
    rigthVideo.setTranslationX(videoSize/2); 

이 보이는 방법은 다음과 같습니다 :이처럼 보이는

enter image description here

관련 문제