2

I have video calling app that having 2 layout: one for local video view and the another one for remote video view. what I want to do is to make the remote video view to be transparent and place it over local video view.

I already tried to add android:background:@colour/transparent or android:alpha:"0.5" in the xml layout but both of that doesn't work. any suggestion for this issue? thanks

this is my xml layout

<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_video_chat_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".CallActivity">



<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="4"
    android:background="@android:color/darker_gray"
    android:orientation="vertical"
    android:padding="0dip">

<FrameLayout
    android:id="@+id/remote_video_view_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white"
    />

<FrameLayout
    android:id="@+id/local_video_view_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentEnd="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:layout_marginEnd="@dimen/activity_horizontal_margin"
    android:layout_marginRight="@dimen/activity_horizontal_margin"
    android:layout_marginTop="@dimen/activity_vertical_margin"
    android:background="@android:color/darker_gray"
    android:alpha="0.5"/>


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:orientation="horizontal"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="@dimen/activity_vertical_margin"
        android:layout_marginRight="@dimen/activity_horizontal_margin"
        android:layout_marginTop="@dimen/activity_vertical_margin"
        android:layout_marginLeft="@dimen/activity_horizontal_margin">

        <ImageView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="20"
            android:onClick="onLocalVideoMuteClicked"
            android:scaleType="centerInside"
            android:src="@drawable/btn_voice" />

        <ImageView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="20"
            android:onClick="onLocalAudioMuteClicked"
            android:scaleType="centerInside"
            android:src="@drawable/btn_mute" />

        <ImageView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="20"
            android:onClick="onSwitchCameraClicked"
            android:scaleType="centerInside"
            android:src="@drawable/btn_switch_camera" />

        <ImageView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="20"
            android:onClick="onEncCallClicked"
            android:scaleType="centerInside"
            android:src="@drawable/btn_end_call" />

        <ImageView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="20"
            android:scaleType="centerInside"
            android:src="@drawable/sc"
            android:onClick="save"/>

        <ImageView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="20"
            android:scaleType="centerInside"
            android:src="@drawable/draw" />

    </LinearLayout>

</RelativeLayout>

<LinearLayout
    android:id="@+id/layout1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="@dimen/activity_vertical_margin"
    android:orientation="vertical">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/activity_horizontal_margin"
        android:layout_marginStart="@dimen/activity_horizontal_margin"
        android:gravity="center_vertical|start"
        android:text="Waiting for remote users"/>

    <TextView
        android:id="@+id/txChannelName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="40dp"
        android:layout_marginLeft="@dimen/activity_horizontal_margin"
        android:layout_marginStart="@dimen/activity_horizontal_margin"
        android:gravity="center_vertical|start" />

</LinearLayout>

</RelativeLayout>
nhoxbypass
  • 9,299
  • 11
  • 44
  • 64
Prasetyo
  • 181
  • 1
  • 3
  • 15
  • if your issue related to design part then post a sample image or mock-up, that'll help others to find out what you want exactly. – Arnold Brown Nov 22 '17 at 10:31

2 Answers2

0

I think you first write remote video View and after write Local video View inside XML Try it may be useful

SahdevRajput74
  • 750
  • 7
  • 18
  • remote video view before local video view ? yes i did it. check my xml code – Prasetyo Nov 22 '17 at 09:13
  • i mean you should write remoteVideo view after localview not before – SahdevRajput74 Nov 22 '17 at 09:15
  • last added view will appear on top view on screen so you can set alpha on top view it will effect if it is top view of all view so You want to make local view transparent so write local view after remote view – SahdevRajput74 Nov 22 '17 at 09:17
0

First off you need to switch the order of the views, put the remote view below the local view in the XML (further down in the XML, higher up in the view hierarchy):

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_video_chat_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".CallActivity">

    <!-- ... -->

    <FrameLayout
        android:id="@+id/local_video_view_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:layout_marginEnd="@dimen/activity_horizontal_margin"
        android:layout_marginRight="@dimen/activity_horizontal_margin"
        android:layout_marginTop="@dimen/activity_vertical_margin"
        android:background="@android:color/darker_gray"/>

    <FrameLayout
        android:id="@+id/remote_video_view_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/white"
        android:alpha="0.5"
        />

    <!-- ... -->

</RelativeLayout>

Second it's sort of hard to help with this without knowing what kind of view the video is shown in. But if you are using a VideoView it's not especially flexible when it comes to animating/changing its view properties. But in that case, try switching to a TextureView, it has better support for animations, like fading.

patrick.elmquist
  • 2,033
  • 2
  • 20
  • 32
  • the video that showing in framelayout is video from videocalling. so my idea is to put the remote video user over the local video and make the remote video view transparent so the local video still visible – Prasetyo Nov 22 '17 at 09:28
  • btw even i switched the layout position like you said, it still doesn't work – Prasetyo Nov 22 '17 at 09:29
  • What type of view are you putting in the FrameLayout? A VideoView, TextureView, SurfaceView? – patrick.elmquist Nov 22 '17 at 09:36
  • its a surfaceview – Prasetyo Nov 22 '17 at 09:55
  • so how ? any suggestion ? – Prasetyo Nov 23 '17 at 01:14
  • Yeah, when I a while back had to fade between two videos, I switched to TextureView instead. I used the marked answer in this StackOverflow post as a reference: https://stackoverflow.com/a/26469753/2281718 TextureView is more lika a regular view and is easier to customize. – patrick.elmquist Nov 23 '17 at 08:44