> For the complete documentation index, see [llms.txt](https://docs.mapbox.com/android/ja/maps/llms.txt)

# Transparent background

![MapView with transparent background.](https://docs.mapbox.com/android/ja/assets/ideal-img/maps-examples-transparent-background.05f7255.480.png)

This example demonstrates using a custom video as a background for a [MapView](https://docs.mapbox.com/android/maps/api/latest/mapbox-maps-android/com.mapbox.maps/-map-view/) in the **Mapbox Maps SDK for Android**. By leveraging the [`texture_view`](https://developer.android.com/reference/android/view/TextureView) rendering for the `MapView`, the background video can have alpha channel translucency. The `TransparentBackgroundActivity` class extends `AppCompatActivity` and includes functionality to load a custom video (`moving_background_water`) as the background video.

In the `onCreate` method, the custom [JSON style](https://docs.mapbox.com/help/glossary/style/) containing map layer information is loaded using [`mapboxMap.loadStyle`](https://docs.mapbox.com/android/maps/api/latest/mapbox-maps-android/com.mapbox.maps/-mapbox-map/load-style.html). This method initializes the background video view (`videoView`) by setting the video URI and starting playback. When the video playback completes, the app automatically sets it to replay. The `onDestroy` method ensures the video playback is stopped when the activity is destroyed.

> **Note: Android Examples App Available**
> 
> This example code is part of the **Maps SDK for Android Examples App**, a working Android project [available on GitHub](https://github.com/mapbox/mapbox-maps-android/tree/v11.29.0/). Android developers are encouraged to run the examples app locally to interact with this example in an emulator and explore other features of the Maps SDK.
> 
> See our [Run the Maps SDK for Android Examples App](https://docs.mapbox.com/help/tutorials/maps-sdk-android-examples-app/) tutorial for step-by-step instructions.

**Kotlin**

Title: `TransparentBackgroundActivity.kt`

[View on GitHub](https://github.com/mapbox/mapbox-maps-android/blob/v11.29.0/app/src/main/java/com/mapbox/maps/testapp/examples/TransparentBackgroundActivity.kt)

```kt
package com.mapbox.maps.testapp.examples

import android.net.Uri
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.mapbox.maps.testapp.R
import com.mapbox.maps.testapp.databinding.ActivityTransparentBackgroundBinding

/**
 * Example of using custom video as a background for MapView.
 * This is possible when using `texture_view` rendering for MapView because it supports alpha channel translucency.
 */
class TransparentBackgroundActivity : AppCompatActivity() {

  private lateinit var binding: ActivityTransparentBackgroundBinding

  private fun initVideoView() {
    val path = "android.resource://" + packageName + "/" + R.raw.moving_background_water
    binding.videoView.apply {
      setVideoURI(Uri.parse(path))
      start()
      setOnCompletionListener { binding.videoView.start() }
    }
  }

  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    binding = ActivityTransparentBackgroundBinding.inflate(layoutInflater)
    setContentView(binding.root)

    binding.mapView.mapboxMap.loadStyle(
      """
      {
        "version": 8,
        "name": "Land",
        "metadata": {
          "mapbox:autocomposite": true
        },
        "sources": {
          "composite": {
            "url": "mapbox://mapbox.mapbox-terrain-v2",
            "type": "vector"
          }
        },
        "glyphs": "mapbox://fonts/mapbox/{fontstack}/{range}.pbf",
        "layers": [
          {
            "layout": {
              "visibility": "visible"
            },
            "type": "fill",
            "source": "composite",
            "id": "admin",
            "paint": {
              "fill-color": "hsl(359, 100%, 50%)",
              "fill-opacity": 1
            },
            "source-layer": "landcover"
          },
          {
            "layout": {
              "visibility": "visible"
            },
            "type": "fill",
            "source": "composite",
            "id": "layer-0",
            "paint": {
              "fill-opacity": 1,
              "fill-color": "hsl(359, 100%, 50%)"
            },
            "source-layer": "Layer_0"
          }
        ]
      }
      """.trimIndent()
    ) { initVideoView() }
  }

  override fun onDestroy() {
    super.onDestroy()
    binding.videoView.stopPlayback()
  }
}
```

**XML**

Title: `activity_transparent_background.xml`

[View on GitHub](https://github.com/mapbox/mapbox-maps-android/blob/v11.29.0/app/src/main/res/layout/activity_transparent_background.xml)

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

    <VideoView
        android:id="@+id/videoView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleX="10.8"
        android:scaleY="3.8" />

    <com.mapbox.maps.MapView xmlns:mapbox="http://schemas.android.com/apk/res-auto"
        android:id="@+id/mapView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        mapbox:mapbox_cameraTargetLat="48.507879"
        mapbox:mapbox_cameraTargetLng="8.363795"
        mapbox:mapbox_cameraZoom="2"
        mapbox:mapbox_mapSurface="texture_view" />

</FrameLayout>
```