[android] - translucent surface on TextureView
This commit is contained in:
@@ -759,6 +759,17 @@
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_textureview"/>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.textureview.TextureViewTransparentBackgroundActivity"
|
||||
android:description="@string/description_textureview_transparent"
|
||||
android:label="@string/activity_textureview_transparent">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_textureview"/>
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.textureview.TextureViewAnimationActivity"
|
||||
android:description="@string/description_textureview_animate"
|
||||
|
||||
@@ -95,4 +95,4 @@ public class TextureViewResizeActivity extends AppCompatActivity {
|
||||
mapView.onLowMemory();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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 not shown.
|
After Width: | Height: | Size: 162 KiB |
@@ -7,7 +7,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
|
||||
<com.mapbox.mapboxsdk.maps.MapView
|
||||
android:id="@+id/mapView"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -67,6 +67,7 @@
|
||||
<string name="description_textureview_debug">Use TextureView to render the map</string>
|
||||
<string name="description_textureview_resize">Resize a map rendered on a TextureView</string>
|
||||
<string name="description_textureview_animate">Animate a map rendered on a TextureView</string>
|
||||
<string name="description_textureview_transparent">Enable a transparent surface on TextureView</string>
|
||||
<string name="description_grid_source">Example Custom Geometry Source</string>
|
||||
<string name="description_local_glyph">Suzhou using Droid Sans for Chinese glyphs</string>
|
||||
<string name="description_hillshade">Example raster-dem source and hillshade layer</string>
|
||||
|
||||
@@ -67,6 +67,7 @@
|
||||
<string name="activity_textureview_debug">TextureView debug</string>
|
||||
<string name="activity_textureview_resize">TextureView resize</string>
|
||||
<string name="activity_textureview_animate">TextureView animation</string>
|
||||
<string name="activity_textureview_transparent">TextureView transparent background</string>
|
||||
<string name="activity_grid_source">Grid Source</string>
|
||||
<string name="activity_local_glyph">Local CJK glyph generation</string>
|
||||
<string name="activity_hillshade">Hillshade</string>
|
||||
|
||||
Reference in New Issue
Block a user