This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[android] - translucent surface on TextureView
- Loading branch information
Showing
17 changed files
with
233 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,4 +95,4 @@ public void onLowMemory() { | |
mapView.onLowMemory(); | ||
} | ||
|
||
} | ||
} |
94 changes: 94 additions & 0 deletions
94
...pbox/mapboxsdk/testapp/activity/textureview/TextureViewTransparentBackgroundActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package com.mapbox.mapboxsdk.testapp.activity.textureview; | ||
|
||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.widget.ImageView; | ||
|
||
import com.mapbox.mapboxsdk.maps.MapView; | ||
import com.mapbox.mapboxsdk.maps.MapboxMap; | ||
import com.mapbox.mapboxsdk.testapp.R; | ||
import com.mapbox.mapboxsdk.testapp.utils.ResourceUtils; | ||
|
||
import java.io.IOException; | ||
|
||
import timber.log.Timber; | ||
|
||
/** | ||
* Example showcasing how to create a TextureView with a transparent background. | ||
*/ | ||
public class TextureViewTransparentBackgroundActivity extends AppCompatActivity { | ||
|
||
private MapView mapView; | ||
private MapboxMap mapboxMap; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_textureview_transparent); | ||
setupBackground(); | ||
setupMapView(savedInstanceState); | ||
} | ||
|
||
private void setupBackground() { | ||
ImageView imageView = (ImageView) findViewById(R.id.imageView); | ||
imageView.setImageResource(R.drawable.water); | ||
imageView.setScaleType(ImageView.ScaleType.FIT_XY); | ||
} | ||
|
||
private void setupMapView(Bundle savedInstanceState) { | ||
mapView = (MapView) findViewById(R.id.mapView); | ||
mapView.onCreate(savedInstanceState); | ||
mapView.getMapAsync(map -> { | ||
mapboxMap = map; | ||
|
||
try { | ||
map.setStyleJson(ResourceUtils.readRawResource(getApplicationContext(), R.raw.no_bg_style)); | ||
} catch (IOException exception) { | ||
Timber.e(exception); | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
protected void onStart() { | ||
super.onStart(); | ||
mapView.onStart(); | ||
} | ||
|
||
@Override | ||
protected void onResume() { | ||
super.onResume(); | ||
mapView.onResume(); | ||
} | ||
|
||
@Override | ||
protected void onPause() { | ||
super.onPause(); | ||
mapView.onPause(); | ||
} | ||
|
||
@Override | ||
protected void onStop() { | ||
super.onStop(); | ||
mapView.onStop(); | ||
} | ||
|
||
@Override | ||
protected void onSaveInstanceState(Bundle outState) { | ||
super.onSaveInstanceState(outState); | ||
mapView.onSaveInstanceState(outState); | ||
} | ||
|
||
@Override | ||
protected void onDestroy() { | ||
super.onDestroy(); | ||
mapView.onDestroy(); | ||
} | ||
|
||
@Override | ||
public void onLowMemory() { | ||
super.onLowMemory(); | ||
mapView.onLowMemory(); | ||
} | ||
|
||
} |
Binary file added
BIN
+162 KB
platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/water.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...ndroid/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_textureview_transparent.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<android.support.design.widget.CoordinatorLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:id="@+id/coordinator_layout" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical"> | ||
|
||
<ImageView | ||
android:id="@+id/imageView" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:contentDescription="@null"/> | ||
|
||
<com.mapbox.mapboxsdk.maps.MapView | ||
android:id="@+id/mapView" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
app:mapbox_cameraTargetLat="48.507879" | ||
app:mapbox_cameraTargetLng="8.363795" | ||
app:mapbox_cameraZoom="2" | ||
app:mapbox_renderTextureMode="true" | ||
app:mapbox_renderTextureTranslucentSurface="true" | ||
app:mapbox_styleUrl="mapbox://styles/agerace-globant/cja02de7193b02suvy4gpbt2c"/> | ||
|
||
</android.support.design.widget.CoordinatorLayout> | ||
|
43 changes: 43 additions & 0 deletions
43
platform/android/MapboxGLAndroidSDKTestApp/src/main/res/raw/no_bg_style.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"version": 8, | ||
"name": "Land", | ||
"metadata": { | ||
"mapbox:autocomposite": true, | ||
}, | ||
"sources": { | ||
"composite": { | ||
"url": "mapbox://mapbox.mapbox-terrain-v2", | ||
"type": "vector" | ||
} | ||
}, | ||
"sprite": "mapbox://sprites/mapbox/mapbox-terrain-v2", | ||
"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" | ||
} | ||
] | ||
} |
Oops, something went wrong.