Android bitmap image size in XML

后端 未结 8 1054
情书的邮戳
情书的邮戳 2020-12-08 03:34

In my XML file, I\'m using bitmap as the following


Here t

8条回答
  •  离开以前
    2020-12-08 04:35

    From Android Developers I saw that there is no tag for Bitmap XML that allow you to change it size. You need to do this via some Graphic Applications like GIMP. As @Kevin Cooper told already, ideally you need to create different sets of resources (with different sizes) for different screen types.

    But still you can resize it using width and height attributes in ImageView, instead of creating bitmap with different size:

    
    

    If you want to reuse this image in other places, you can create separate style and reuse it:

    // in styles.xml
    
    
    // in layout.xml
    
    

    Another way of reusing, may be creating of separate layout file for one ImageView and then including in to other layouts.

    If you want to use this bitmap inside of layer list, please see @Kevin Cooper answer, as he suggested it is possible to add paddings to layer list item:

    
        
            
        
    
    

    And as @Nicolo also pointed, form API 23, it is possible to set android:width and android:height" to item.

提交回复
热议问题