Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Commit

Permalink
Adding multiple color formatting to TextFieldMultipleFormatsActivity (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Langston Smith authored May 9, 2019
1 parent 162f46d commit dcdc444
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mapbox.mapboxandroiddemo.examples.styles;

import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
Expand All @@ -14,6 +15,7 @@
import com.mapbox.mapboxsdk.style.layers.Layer;

import static com.mapbox.mapboxsdk.style.expressions.Expression.FormatOption.formatFontScale;
import static com.mapbox.mapboxsdk.style.expressions.Expression.FormatOption.formatTextColor;
import static com.mapbox.mapboxsdk.style.expressions.Expression.FormatOption.formatTextFont;
import static com.mapbox.mapboxsdk.style.expressions.Expression.format;
import static com.mapbox.mapboxsdk.style.expressions.Expression.formatEntry;
Expand All @@ -22,8 +24,8 @@


/**
* Use runtime styling to create labels with a SymbolLayer that include multiple
* text fonts and sizes.
* Use runtime styling to create labels with a SymbolLayer that include multiple text
* languages, fonts, sizes, and colors.
*/
public class TextFieldMultipleFormatsActivity extends AppCompatActivity {

Expand Down Expand Up @@ -53,16 +55,19 @@ public void onStyleLoaded(@NonNull final Style style) {
Expression.FormatEntry bigLabel = formatEntry(
get("name_en"),
formatFontScale(1.5),
formatTextColor(Color.BLUE),
formatTextFont(new String[] {"Ubuntu Medium", "Arial Unicode MS Regular"})
);

Expression.FormatEntry newLine = formatEntry(
// Add "\n" in order to break the line and have the second label underneath
"\n",
formatFontScale(0.5)
);

Expression.FormatEntry smallLabel = formatEntry(
get("name"),
formatTextColor(Color.parseColor("#d6550a")),
formatTextFont(new String[] {"Caveat Regular", "Arial Unicode MS Regular"})
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<string name="activity_style_image_source_description">Use an image source to easily display images on the map.</string>
<string name="activity_style_hillshade_description">Use elevation data to show and customize hills and mountains.</string>
<string name="activity_styles_fade_switch_description">Fade map styles in and out based on zoom level.</string>
<string name="activity_styles_text_field_multiple_formats_description">Use a format expression to style labels in multiple ways.</string>
<string name="activity_styles_text_field_multiple_formats_description">Use a format expression to style labels with multiple languages, fonts, sizes, and colors.</string>
<string name="activity_styles_transparent_background_description">Create a transparent background and fill it with something such as moving water.</string>
<string name="activity_styles_click_to_add_image_description">Select a photo on the device and add it on the map tap location.</string>
<string name="activity_styles_rotating_anchor_text_description">Adjust the anchor position of SymbolLayer text fields.</string>
Expand Down
2 changes: 1 addition & 1 deletion MapboxAndroidDemo/src/main/res/values/urls_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<string name="activity_style_image_source_url" translatable="false">https://i.imgur.com/I6B6cCE.png</string>
<string name="activity_style_hillshade_url" translatable="false">https://i.imgur.com/U2OKixV.png</string>
<string name="activity_styles_fade_switch_url" translatable="false">https://i.imgur.com/1sPnDx5.png</string>
<string name="activity_styles_text_field_multiple_formats_url" translatable="false">https://i.imgur.com/OIbBFI5.png</string>
<string name="activity_styles_text_field_multiple_formats_url" translatable="false">https://i.imgur.com/dpiGiTg.png</string>
<string name="activity_styles_transparent_background_url" translatable="false">https://i.imgur.com/5bYnlp5.png</string>
<string name="activity_styles_click_to_add_image_url" translatable="false">https://i.imgur.com/uPIH5Ck.png</string>
<string name="activity_styles_rotating_anchor_text_url" translatable="false">https://i.imgur.com/w8cP6Wn.png</string>
Expand Down

0 comments on commit dcdc444

Please sign in to comment.