Asked  7 Months ago    Answers:  5   Viewed   32 times

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-large and layout.

Then I've created different folder for image: ldpi, mdpi and hdpi. In all drawable folder the image must be with different size true? I ask this cause of I have a phone with screen size large and density medium, the image shown will be smaller and they will not take the right size?



For Different screen size, The following is a list of resource directories in an application that provides different layout designs for different screen sizes and different bitmap drawables for small, medium, high, and extra high density screens.

res/layout/my_layout.xml             // layout for normal screen size ("default")
res/layout-small/my_layout.xml       // layout for small screen size
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

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

The following code in the Manifest supports all dpis.

<supports-screens android:smallScreens="true" 
          android:anyDensity="true" />

And also check out my SO answer.

Tuesday, June 1, 2021
answered 7 Months ago

Basically some devices belongs to large or normal group but they have so much difference in height and width for example- Nexus-4 4.7" having dimensions 768x1280 and one other device 5.1" having dimensions 480x800. So you can create layouts folders depending upon height and width. For example- layout-w480dp, layout-w720dp or layout-h800dp or layout-h1280dp. Then set views in those layouts according to your requirement.

Sunday, August 29, 2021
answered 3 Months ago

Have you designed the app using fixed widths and heights? You should definitely use the capabilities of flexbox and try to avoid settings fixed sizes as much as possible. The flex property can be used to define how much space a <View /> should use releative to others, and the other properties on that page can be used to lay out elements in a flexible way that should give the desired results on a range of different screen sizes.

Sometimes, you may also need a <ScrollView />.

When you do need fixed sizes, you could use Dimensions.get('window').

Monday, September 27, 2021
Mawg says reinstate Monica
answered 2 Months ago

Try this:

public void onCreate(Bundle savedInstanceState) {
    LinearLayout v = (LinearLayout) findViewById(;
    v.setDrawingCacheEnabled(true); Runnable() {
        public void run() {
             // Code to take screenshot

Sunday, October 3, 2021
answered 2 Months ago

The androidscreenshot project does exactly that, but you will need to run as root or have your binary signed by the vendor key (i.e. the same key that was used when compiling the OS). There are plenty of discussions about this restriction here and elsewhere on the Internet.

Wednesday, October 27, 2021
Pierre Schambacher
answered 1 Month ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :