在地图V2使用自定义字样 [英] Using Custom Typeface in Maps V2

查看:221
本文介绍了在地图V2使用自定义字样的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图定义片段和放大器的看法;标题中使用图形页面<一个href=\"http://stackoverflow.com/questions/14123243/google-maps-api-v2-custom-infowindow-like-in-original-android-google-maps?lq=1#comment19551415_14123243\">CommonsWare's例如结果但是我不能够自定义代码段在字样。结果自定义代码片段MapsV2结果
 任何运气?

Am trying to customize the view of Snippet & Title in MapView using CommonsWare's Example
However am not able to Customize the Typeface of the snippet.

Any luck?

推荐答案

如果您从扩展的CommonsWare例如,你应该有一个PopupAdapter负责显示您的信息窗口。

If you extended the example from CommonsWare, you should have a PopupAdapter which is responsible for displaying your InfoWindow.

我已经扩展了PopupAdapter从我的资产文件夹中加载一个字体,并将其设置为标题和摘要的意见字体

I've extended that PopupAdapter to load a Typeface from my assets folder, and set it as the title and snippet views typeface

class PopupAdapter implements InfoWindowAdapter {
    LayoutInflater inflater = null;

    // Context is most likely the map hosting activity. 
    // We need this so we get access to the Asset Manager
    Context context = null;

    PopupAdapter(LayoutInflater inflater, Context context) {
        this.inflater = inflater;
        this.context = context;
    }

    @Override
    public View getInfoWindow(Marker marker) {
        return (null);
    }

    @Override
    public View getInfoContents(Marker marker) {
        View popup = inflater.inflate(R.layout.popup, null);

        TextView tv = (TextView) popup.findViewById(R.id.title);

        tv.setText(marker.getTitle());

        // We load a typeface by using the static createFromAssets method
        // and provide the asset manager 
        // and a path to the file within the assets folder
        Typeface tf = Typeface.createFromAsset(context.getAssets(),
                "GoodDog.otf");
        // then set the TextViews typeface
        tv.setTypeface(tf);
        tv = (TextView) popup.findViewById(R.id.snippet);
        tv.setText(marker.getSnippet());
        tv.setTypeface(tf);

        return (popup);
    }
}

这篇关于在地图V2使用自定义字样的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆