Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating multi-screen support app android

I am creating a app in Android that must support multiple screens.

For this purpose i have read many answers and one which i like most is state that i can create different folders in res folder by following name,

For small screens layout-small,

For large screens layout-large,

For extra large screens layout-xlarge

and i have to create different layouts for different screens with same name. e.g mylayout.xml

and i have to put following code in manifest.xml file

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

and finally i just need to write following lines in my Activity file,

  setContentView(R.layout.mylayout);

Now when i run this app in different size screens it should acquire layouts from different folders as per screen resolution.

But this is not happening in my case.It takes only layout that defined in layout folder.

Please can some one explains me why this happening and how can i solve this issue so that my app can run effectively on all size screens.

like image 389
Jay Vyas Avatar asked Mar 29 '14 07:03

Jay Vyas


People also ask

How do I force an app to Split screen on Android?

Step 1: Tap & hold the recent button on your Android Device –>you will see all the recent list of applications listed in chronological order. Step 2: Select one of the apps you wish to view in split screen mode –>once the app opens, tap & hold the recent button once again –>The screen will split into two.

Can I run 2 apps at once on Android?

You can use split screen mode on Android devices to view and use two apps simultaneously. Using split screen mode will deplete your Android's battery faster, and apps that require the full screen to function won't be able to run in split screen mode. To use split screen mode, head to your Android's "Recent Apps" menu.

Do all apps support Split screen?

Tap the desired app's icon, and then tap Open in split screen view. This app will be pinned to the top window. Note: Not all apps support split screen view. To open a second app in the bottom window, simply open the desired app from the list.


2 Answers

Try out like:

  • layout-sw320dp
  • layout-sw480dp
  • layout-sw600dp
  • layout-sw720dp

instead of

  • layout-small,
  • layout-large etc...
like image 191
Arun Antoney Avatar answered Sep 30 '22 10:09

Arun Antoney


Please refer below link:

http://developer.android.com/guide/practices/screens_support.html 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. you could use different size of the layout files in res folder and also vary for drawable images based on the density..

  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

enter image description here 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

<compatible-screens>
    <screen
        android:screenDensity="ldpi"
        android:screenSize="small" />
    <screen
        android:screenDensity="mdpi"
        android:screenSize="normal" />
    <screen
        android:screenDensity="xhdpi"
        android:screenSize="large" />
    <screen
        android:screenDensity="xhdpi"
        android:screenSize="xlarge" />        
</compatible-screens>

And followed by any activity use this lines..

android:configChanges="orientation|screenSize|keyboardHidden"

like image 23
Sethu Avatar answered Sep 30 '22 12:09

Sethu