How to center vector drawable in layer-list without scaling

后端 未结 4 1000
伪装坚强ぢ
伪装坚强ぢ 2020-12-12 17:11

I am attempting to use a VectorDrawable in a LayerList without scaling the vector. For example:


    

        
4条回答
  •  眼角桃花
    2020-12-12 17:37

    I'm currently working on a splash screen with a vector drawable centered both horizontally and vertically. Here is what I got on API level 25:

    
    
    
    
    
    
    
    
    
    

    If you want to adjust the vector drawable's dimension, modify android:width and android:height attributes above, not necessarily modify the original drawable.

    In addition, my experience is DO NOT put the vector drawable in a bitmap tag, which never works for me. Bitmap is for .png, .jpg and .gif format file, not for vector drawable.

    Reference

    https://developer.android.com/guide/topics/resources/drawable-resource#LayerList

    https://developer.android.com/guide/topics/resources/more-resources.html#Dimension

提交回复
热议问题