SVG image or PNG image

1

I would like to know if it is possible to guide me about loading svg images into a FrameLayout element.

I have a LinearLayout element where inside there is a WebView and a FrameLayout , within this FrameLayout I have 3 images given the versions of the S.O. they must be in PNG format or SVG format. How is it possible to integrate an SVG or PNG image according to the version of the S.O., respectively?

    
asked by Rodrigo 19.04.2016 в 18:17
source

2 answers

0

If you want to perform some validation by API in your code you can do it through the class Build , this is an example, assuming support for SVG is available in OSs larger than Android 21 (Lollipop):

if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP){
    //Si es mayor a Lollipop cargar FrameLayout con SVG.
} else {
    //Usa FrameLayout  con PNG.
}

Here you will find the list of constants to perform your validation: link

How do you comment that your validation would show images .png in api 11, HoneyComb , this would be an example:

if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB){
    //Si es mayor a Honeycomb (api 11) usa SVG.
} else {
    //Usa PNG.
}
    
answered by 19.04.2016 / 20:43
source
0

You can perform two methods of loading one for PNG and another for SVG, once you have these you only verify the version and depending on the device you launch the corresponding methods.

Code to verify versions:

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.NOMBREDELAVERSION){

             //Si es mayor o igual a la version cargar SVG.

    } else {

             //Dado que es menor cargar PNG.

    }
    
answered by 19.04.2016 в 19:41