3

I'm trying to support all kind of screens on my project. I added the the respective graphics in the folders-drawables(ldpi,mdpi,Hdpi,xhdpi,xxhdpi),, And also the layouts folders(layout-small,layout,layout-large,layout-xlarge,layout-xxlarge). Here is the thing: When I open the app on the emulator,on a normal screen(mdpi),.everythings is right, But when I choose other emulator like one Hdpi/large,.the android system is not choosing the right graphics.(for example I open a Hdpi emulator and the system is choosing the normal graphics(mdpi).

What do I need to do?,do I need to write some code to force the system choose the right graphics ?,really needing help !

Chapo
  • 31
  • 1
  • 7
  • Android choses the RIGHT layout and DPI drawables, it's your graphics that are wrong :) Trust me. – Martin Marconcini Feb 01 '14 at 23:25
  • @MartínMarconcini how can my graphics be wrong ? – Chapo Feb 02 '14 at 01:33
  • how can they be wrong,if for example im targeting a hdpi screen (400px x 854px - at least)im making the backgrounds the same dimension(400px x 854px)and im putting the background on the hdpi folder,and then designing the Layout-large/main.xml – Chapo Feb 02 '14 at 01:43
  • I've read this two links,.. http://developer.android.com/guide/topics/resources/accessing-resources.html http://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources it should be choosing the right graphics/layouts – Chapo Feb 02 '14 at 01:44

1 Answers1

0

You should be changing the dpi values between every view type so they look appropriate in each view. On the webpage Supporting Multiple Screens, there is a chart that displays the minimum screen sizes for the different screens. You will have to do some algebra to compare each of the values so you can translate an image's dpi from one size to another. However, another solution is to use "match_parent" and "wrap_content" as opposed to using defined sizes, as it simplifies the process. The same process applies to sp for text in the views.

The chart I am referring to is the one that looks like this:

  • xlarge screens are at least 960dp x 720dp

  • large screens are at least 640dp x 480dp

  • normal screens are at least 470dp x 320dp

  • small screens are at least 426dp x 320dp

EDIT: I also forgot to mention that if you use multiple views in a LinearLayout, you can use the android property called android:layout_weight to use a ratio to divide up the screen.


EDIT: Then perhaps the problem is that you don't have your images scaled properly. Maybe you should try adding these to your ImageViews:

android:adjustViewBounds="true"
android:scaleType="fitXY"
Steven Zahuranec
  • 238
  • 1
  • 3
  • 10
  • i did my layout graphics(backgrounds) like this: *ldpi 240 x 320 *mdpi 320 x 480 *hdpi 480 x 800 *xhdpi 720 x 1280 *xxhdpi 1080 x 1920 – Chapo Feb 02 '14 at 04:17
  • Maybe you should try to setting the scaleType for your ImageViews to fitXY and set adjustViewBounds to true. – Steven Zahuranec Feb 02 '14 at 05:39
  • What is that?,how can I try that? – Chapo Feb 02 '14 at 05:50
  • It will be in the .xml file that you are modifying. Specifically, it is an option that is inherited from ImageView. In xml you would have to add: android:adjustViewBounds="true" android:scaleType="fitXY" to your ImageView. – Steven Zahuranec Feb 02 '14 at 05:52
  • Mmm, I have no idea if that would work,but , the graphics that android system is not choosing right is on : – Chapo Feb 02 '14 at 21:47
  • I have no imageview(s) on the layout,I just have textviews and buttons.the android system is not choosing the right background;other thing, on my menu.xml(normal or mdpi,on the layout folder),I have it like this(android:background="@drawable/bgm")and on the folder layout-large(the same xml "menu.xml"),i have like android:background="@drawable/bgh",I have no idea if the graphics need to have the same name(like just call the background just bg and make different sizes(like 240x320,320x480 & so on)with the same name & put them in its own folders(240x320 on ldpi folder,320x480 on mdpi,& so on) – Chapo Feb 02 '14 at 22:04
  • I'm not sure then. This may be a long shot, but maybe you can use a FrameView instead by putting both the ImageView and the text for the button in the FrameView. – Steven Zahuranec Feb 03 '14 at 02:26
  • Then you can implement an OnClickListener in your activity for the ImageView. – Steven Zahuranec Feb 03 '14 at 02:27
  • im not sure if we are on the same "channel",.im not trying to load a picture on a image view,.im just putting a picture as background,..i think thats this line for (android:background="@drawable/bgh")it should load that photo as background,and without the need of the last comments you wrote to me,.. – Chapo Feb 03 '14 at 03:31
  • @Chapo Are you just using one layout folder or do you have multiple layout folders? – Steven Zahuranec Feb 03 '14 at 04:38
  • yes Steven im using multiple layout folders(layout,layout-large,layout-xlarge) – Chapo Feb 04 '14 at 01:58