-5

I have created layout programmatically in my android application.

Here I have developed like horizontal listview with images.

I have to run the app which means I am getting the

  • 2 images on small screen.
  • 3 images displayed on medium screen.
  • 5 images displayed on large screen.

But I wish to display the same design on all screen. i wish to display 3 images on small,medium,large and xlarge screen.

How can I do this?

Is it possible to display ? .

  • [check this link](http://stackoverflow.com/questions/11252067/how-do-i-get-the-screensize-programmatically-in-android) and depending on screen size you make the things to work – Zombie Mar 14 '13 at 06:09
  • @user2163875 Please remove the words **give me solution for this**. Its not welcome. Please ask for help or suggestions rather then asking for complete code or solution. – Harpreet Mar 14 '13 at 06:40

2 Answers2

2

Create folders like specified in the image

You have to create folders with the following names:

1) layout

2) layout-large

3) layout-xlarge

4) layout-480x320

Create your layout in xml and adjust the layout settings in other related layouts. You place xml layout files (Which are same in terms of name) in all of these folders and design them accordingly.

Skynet
  • 7,820
  • 5
  • 44
  • 80
  • yes these i know....but i have created layout programmatically...thats y am asking the question is like above.how can i display same design on all screens for programmtically created layout files... – user2163875 Mar 14 '13 at 06:05
  • 1
    The above is the preffered way to do it, I do not know of any method apart from this. – Skynet Mar 14 '13 at 06:42
1

You can achieve this either by creating XML Layouts in res/layout, res/layout-small, res/layout-large etc.

But, if you still want to go for layout from Java class, then study about BUILD in Android or go can go through the below question:-

Determine device screen category (small, normal, large, xlarge) using code

Let us know if you face any issue.

Community
  • 1
  • 1
Harpreet
  • 2,990
  • 3
  • 38
  • 52