0

I am using SVGImageview for displaying SVG image but it is not occupying the whole screen as shown below:

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    //ImageView imageView = (ImageView)findViewById(R.id.imageView);
    //imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
    //imageView.setAdjustViewBounds(true);
}
}

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <com.caverock.androidsvg.SVGImageView
        android:id="@+id/imageView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/ic_load_bg"
        android:scaleType="fitXY">
    </com.caverock.androidsvg.SVGImageView>
</LinearLayout>

Can someone help me how to do this for any screen size? I found this link to be similar to what I am trying to do here but it didn't give me any hints.

enter image description here

noman pouigt
  • 906
  • 11
  • 25

1 Answers1

0

Looking at https://github.com/BigBadaboom/androidsvg/blob/master/androidsvg/src/main/java/com/caverock/androidsvg/SVGImageView.java

It seems it is looking for "app:svg" attribute instead of "android:src". Also looking for some css to create picture object which is rendered.

private void  doRender()
{
    if (svg == null)
    return;
    Picture  picture = this.svg.renderToPicture(renderOptions);
    setSoftwareLayerType();
    setImageDrawable(new PictureDrawable(picture));
}

One more helpful link is http://bigbadaboom.github.io/androidsvg/SVGImageView.html Additional info: Android has tools like LayoutInspector to inspect layout. Through studio you can convert you svg file to different format, and can use Image view directly the way you are doing.