本文整理汇总了Java中com.caverock.androidsvg.SVG.getDocumentWidth方法的典型用法代码示例。如果您正苦于以下问题:Java SVG.getDocumentWidth方法的具体用法?Java SVG.getDocumentWidth怎么用?Java SVG.getDocumentWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.caverock.androidsvg.SVG
的用法示例。
在下文中一共展示了SVG.getDocumentWidth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadFlag
import com.caverock.androidsvg.SVG; //导入方法依赖的package包/类
@Override
public boolean loadFlag(View view, int imageViewId, String langId) {
ImageView imageView = (ImageView) view.findViewById(imageViewId);
// read a flag from the assets folder
SVG svg = null;
try {
svg = SVG.getFromAsset(MyApp.getAppContext().getAssets(), "flags/" + langId + ".svg");
} catch (SVGParseException | IOException e) {
return false;
}
// create a canvas to draw onto
if (svg.getDocumentWidth() != -1) {
Bitmap bitmap = Bitmap.createBitmap((int) Math.ceil(svg.getDocumentWidth()),
(int) Math.ceil(svg.getDocumentHeight()),
Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
// clear background to white
canvas.drawRGB(255, 255, 255);
// render the flag onto our canvas
svg.renderToCanvas(canvas);
// draw flag on imageView
imageView.setImageBitmap(bitmap);
}
return true;
}
示例2: transcode
import com.caverock.androidsvg.SVG; //导入方法依赖的package包/类
@Override
public Resource<PictureDrawable> transcode(Resource<SVG> toTranscode) {
SVG svg = toTranscode.get();
Picture picture;
if (svg.getDocumentWidth() != -1) {
svg.setDocumentPreserveAspectRatio(PreserveAspectRatio.FULLSCREEN);
picture = svg.renderToPicture();
} else {
picture = svg.renderToPicture(mDeviceWidth, Math.round(mDeviceWidth/svg.getDocumentAspectRatio()));
}
PictureDrawable drawable = new PictureDrawable(picture);
return new SimpleResource<>(drawable);
}
示例3: onDataChange
import com.caverock.androidsvg.SVG; //导入方法依赖的package包/类
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Log.d("MAP", "Users nearby:");
for(DataSnapshot user : dataSnapshot.getChildren()) {
// skip ourselves!
if (user.getKey().equals(FirebaseAuth.getInstance().getCurrentUser().getUid())) {
continue;
}
// check longitude
Double longitude = user.child("location/1").getValue(Double.class);
if (longitude.compareTo(myLatLng.longitude - COORDINATES_OFFSET) < 1 || longitude.compareTo(myLatLng.longitude + COORDINATES_OFFSET) > 1)
continue;
Log.d("MAP", user.child("username").getValue(String.class) != null ? user.child("username").getValue(String.class) : "anonymous");
Double latitude = user.child("location/0").getValue(Double.class);
String username = user.child("username").getValue(String.class);
String userId = user.getKey();
String country = user.child("country").getValue(String.class);
String mood = user.child("mood").getValue(String.class);
String defaultLanguage = user.child("defaultLanguage").getValue(String.class);
MarkerOptions mo = new MarkerOptions()
.data(username)
.draggable(false)
.position(new LatLng(latitude, longitude))
.title(username)
.snippet(country + " | \"" + mood + "\"");
// read a flag from the assets folder
SVG svg = null;
try {
svg = SVG.getFromAsset(MyApp.getAppContext().getAssets(), "flags/" + defaultLanguage + ".svg");
} catch (SVGParseException | IOException e) {
Log.d("MAP", "Error loading svg for default language " + defaultLanguage);
}
// create a canvas to draw onto
if (svg.getDocumentWidth() != -1) {
Bitmap bitmap = Bitmap.createBitmap(100, 75, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
canvas.drawPicture(svg.renderToPicture(), new Rect(0, 0, 100, 75));
mo.icon(BitmapDescriptorFactory.fromBitmap(bitmap));
}
mMap.addMarker(mo);
}
}