本文整理汇总了Java中com.caverock.androidsvg.PreserveAspectRatio类的典型用法代码示例。如果您正苦于以下问题:Java PreserveAspectRatio类的具体用法?Java PreserveAspectRatio怎么用?Java PreserveAspectRatio使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PreserveAspectRatio类属于com.caverock.androidsvg包,在下文中一共展示了PreserveAspectRatio类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: load
import com.caverock.androidsvg.PreserveAspectRatio; //导入依赖的package包/类
/**
* Loading the svg from the resources.
*
* @param context Context object to get the resources.
* @param svgResource int resource id of the svg.
*/
public void load(Context context, int svgResource) {
if (mSvg != null) return;
try {
mSvg = SVG.getFromResource(context, svgResource);
mSvg.setDocumentPreserveAspectRatio(PreserveAspectRatio.UNSCALED);
} catch (SVGParseException e) {
Log.e(LOG_TAG, "Could not load specified SVG resource", e);
}
}
示例2: decode
import com.caverock.androidsvg.PreserveAspectRatio; //导入依赖的package包/类
@Override
public Resource<SVG> decode(InputStream source, int width, int height) throws IOException {
try {
SVG svg = SVG.getFromInputStream(source);
svg.setDocumentHeight(height);
svg.setDocumentWidth(width);
svg.setDocumentPreserveAspectRatio(PreserveAspectRatio.LETTERBOX);
return new SimpleResource<>(svg);
} catch (SVGParseException ex) {
throw new IOException("Cannot load SVG from stream", ex);
}
}
示例3: load
import com.caverock.androidsvg.PreserveAspectRatio; //导入依赖的package包/类
/**
* Loading the svg from the resources.
*
* @param context Context object to get the resources.
* @param svgResource int resource id of the svg.
*/
public void load(Context context, int svgResource) {
if (mSvg != null)
return;
try {
mSvg = SVG.getFromResource(context, svgResource);
mSvg.setDocumentPreserveAspectRatio(PreserveAspectRatio.UNSCALED);
} catch (SVGParseException e) {
Log.e(LOG_TAG, "Could not load specified SVG resource", e);
}
}
示例4: transcode
import com.caverock.androidsvg.PreserveAspectRatio; //导入依赖的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);
}
示例5: load
import com.caverock.androidsvg.PreserveAspectRatio; //导入依赖的package包/类
public void load(Context context, int svgResource) {
if (mSvg != null) return;
try {
mSvg = SVG.getFromResource(context, svgResource);
mSvg.setDocumentPreserveAspectRatio(PreserveAspectRatio.UNSCALED);
} catch (SVGParseException e) {
Log.e(LOG_TAG, "Could not load specified SVG resource", e);
}
}
示例6: load
import com.caverock.androidsvg.PreserveAspectRatio; //导入依赖的package包/类
public void load(Context context, int svgResource) {
if (mSvg != null) return;
try {
mSvg = SVG.getFromResource(context, svgResource);
mSvg.setDocumentPreserveAspectRatio(PreserveAspectRatio.UNSCALED);
} catch (SVGParseException e) {
Log.e("CatChatSvg", "Could not load specified SVG resource", e);
}
}