Skip to content

tpnet/Libgdx-Backend-TextureView-Android

Repository files navigation

LibgdxTextureView

English | 中文

libGDX use TextureView Rendering Modify libGDX's rendering View SurfaceView to TextureView, allowing for transparent layering with native views. The currently latest supported libGDX version is 1.14.0.

Usage

1. Add Dependency

Download the corresponding jar file for your version from the libs folder and add it to your project dependencies.

2. Code Implementation

Configure the following in your AndroidApplication (or the Activity embedded as a View):

// 1. Create configuration
val cfg = AndroidApplicationConfiguration()

// 2. Core: Enable TextureView
cfg.useTextureView = true

// 3. (Optional) Set transparent channels for transparent layering with native Views
cfg.r = 8
cfg.g = 8
cfg.b = 8
cfg.a = 8

// 4. Initialize and use in layout
val mGdxAdapter = MyGdxAdapter()
val mGdxView = initializeForView(mGdxAdapter, cfg)

// Add the generated View to your layout container (e.g., FrameLayout)
binding.container.addView(mGdxView)

3. Why use TextureView?

Compared to the default SurfaceView, TextureView can be manipulated like a normal Android View:

  • Opacity control (can be layered directly with native UI components for displaying).
  • Dynamic property modification (such as setAlpha(), setRotation(), etc.).
  • Animation handling (supports standard Android View property animations).

Effects

Original SurfaceView placed at the bottom effect:

Original SurfaceView placed at the bottom

Original SurfaceView transparent placed at the top effect:

Original SurfaceView transparent placed at the top

Modified TextureView transparent layered with native views effect:

Modified TextureView transparent layered

License

This project is licensed under the MIT License.

About

Libgdx use TextureView Rendering,修改Libgdx为TextureView,可以跟原生的view进行透明层叠

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors