skip to Main Content

I am a bit new to android and developing an app which has 10 full screen background imageviews . after a while working with the app it force closes because of outOfMemory exception. I got every image in the 720 × 1200 px from photoshop designer. I haven’t put different sizes of images in drawable-dpi folders since I am confused how to scale. where am I supposed to put this 720 × 1200 ? in which drawable folder ? Any help or clear explanation would be appreciated . Tnx in advance .

2

Answers


  1. I dont think the solution you are looking for is to use the different drawable resource folders for different screen densities but instead you should check this link: https://developer.android.com/topic/performance/graphics/load-bitmap.html on how to load the bitmaps more efficiently by downsampling before you load them into the Image View and by making sure you release any bitmap that isn’t being used any longer.

    Login or Signup to reply.
  2. You have to create different dimen , layout , images and icon files to support all devices.

    changes in screen density.

    xlarge screens are at least 960dp x 720dp
    large screens are at least 640dp x 480dp
    normal screens are at least 470dp x 320dp
    small screens are at least 426dp x 320dp
    

    Make this layout files, so that it will be same for all devices.

    Give padding ,margin ,font and all properties as per devices.

    res/layout/main_activity.xml           # For handsets (smaller than 600dp available width)
    res/layout-sw600dp/main_activity.xml   # For 7” tablets (600dp wide and bigger)
    res/layout-sw720dp/main_activity.xml   # For 10” tablets (720dp wide and bigger)
    

    For Layout ,

    res/layout/my_layout.xml              // layout for normal screen size ("default")
    res/layout-large/my_layout.xml        // layout for large screen size
    res/layout-xlarge/my_layout.xml       // layout for extra-large screen size
    res/layout-xlarge-land/my_layout.xml  // layout for extra-large in landscape orientation
    

    For Images

    res/drawable-mdpi/graphic.png         // bitmap for medium-density
    res/drawable-hdpi/graphic.png         // bitmap for high-density
    res/drawable-xhdpi/graphic.png        // bitmap for extra-high-density
    res/drawable-xxhdpi/graphic.png       // bitmap for extra-extra-high-density
    

    For Icon

    res/mipmap-mdpi/my_icon.png         // launcher icon for medium-density
    res/mipmap-hdpi/my_icon.png         // launcher icon for high-density
    res/mipmap-xhdpi/my_icon.png        // launcher icon for extra-high-density
    res/mipmap-xxhdpi/my_icon.png       // launcher icon for extra-extra-high-density
    res/mipmap-xxxhdpi/my_icon.png      // launcher icon for extra-extra-extra-high-density
    

    For Launcher icon

    36x36 (0.75x) for low-density
    48x48 (1.0x baseline) for medium-density
    72x72 (1.5x) for high-density
    96x96 (2.0x) for extra-high-density
    180x180 (3.0x) for extra-extra-high-density
    192x192 (4.0x) for extra-extra-extra-high-density (launcher icon only; see note above)
    

    Checkout Dimension and
    Supporting Multiple Screens Official Documentaion.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search