Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
612 views
in Technique[技术] by (71.8m points)

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try out like:

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

instead of

  • layout-small,
  • layout-large etc...

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...