How to support different screen size in android

前端 未结 9 803
天涯浪人
天涯浪人 2020-11-22 05:29

I\'m developing an app in android and I have to support all different screen sizes and density. So i\'ve created different folder for layout : layout-small layout-larg

相关标签:
9条回答
  • 2020-11-22 06:12

    You can figure out the dimensions of the screen dynamically

    Display mDisplay= activity.getWindowManager().getDefaultDisplay();
    int width= mDisplay.getWidth();
    int Height= mDisplay.getHeight();
    

    The layout can be set using the width and the height obtained using this method.

    0 讨论(0)
  • 2020-11-22 06:13

    Adding to @ud_an

    It is not a good practice to create different folders for layouts. Create your layout such that it works fine with all the screen sizes. To achieve this, play with the layout attributes. You only need to have different images for hdpi, mdpi and ldpi types. The rest will be managed by android OS.

    0 讨论(0)
  • 2020-11-22 06:13

    you can create bitmaps for the highes resolution / size your application will run and resize them in the code (at run time)

    check this article http://nuvornapps-en.blogspot.com.es/

    0 讨论(0)
提交回复
热议问题