Reputation: 775
I have an android app with various buttons and text views. The buttons, textviews and edittext fields are spaced around on the screen using measurment of dp. So for example a button will have: 'margintop from left 10dp'
The problem is for high density phones. I have created a new layout for higher density screens and named them either layout-large or layout-sw600-sw720 (as the problem is with galaxy s3).
But the phone still keeps calling the normal layout file which is suited to density screen 480 x 800.
I read that the s3 calls the mormal layout file. So if I change the xml in the normal file to that of the high density, what should I do with the lowere density layout xml? what file name should I call it and will the phone call this file or the normal file again?
Extract of XML layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/duroodscreen"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp" >
<Button
android:id="@+id/dmute"
android:layout_width="48dp"
android:layout_height="33dp"
android:layout_alignParentLeft="true"
android:background="@drawable/soundon" />
<Button
android:id="@+id/dreset"
style="?android:attr/buttonStyleSmall"
android:layout_width="48dp"
android:layout_height="33dp"
android:layout_alignParentRight="true"
android:background="@drawable/customresetbutton" />
<TextView
android:id="@+id/dcount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/dmute"
android:layout_marginLeft="25dp"
android:layout_marginTop="36dp"
android:gravity="center"
android:singleLine="true"
android:text="Numbers"
android:textSize="25sp" />
Refference in Manifest:
<supports-screens
android:resizeable="true"
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:anyDensity="true" />
Upvotes: 0
Views: 644
Reputation: 12293
layout-normal indicates the size of the screen, not the density
you have to create layout-normal-mdpi
and layout-normal-hdpi
files
use layout-normal-xhdpi
for galaxy s3
Upvotes: 1
Reputation: 93708
Why are you using so many pixel values everywhere? Pixel values should only be used for small things like padding a few pixels between elements. The reason for that is to avoid problems like this in the first place.
For example, why are you specifying width and height of the buttons? First off, they have no text so why not use ImageButton? Secondly, just make the images the size you want and use wrap_content. Same with the text field. The idea of an android layout is really to avoid doing all the pixel calculations and instead do everything relatively, so that devices can make their own decision based on their hardware how it will look best.
If you really want to fight the system, it would probably be easier to do it all the way- use an AbsoluteLayout and specify exact pixel coordinates for everything. Otherwise embrace how Android does things or be ready for a world of pain.
Upvotes: 0
Reputation: 43798
Don't confuse screen size with density. The phone has a normal sized screen. So what you see is OK. Also note, the sw600
qualifier refers to a width of 600 dp not pixels.
To provide resources for another density use a density qualifier (mdpi, hdpi, ...).
Upvotes: 1
Reputation: 36045
In this case, as much of a pain it is, it would probably be better to make a layout solely for the Galaxy S3 rather than trying to rewrite everything to correct the mistake of one manufacturer.
Thus you would:
if "galaxy S3"
layout with "my_layout_galaxy_s3"
else -> layout with
layout with "my_layout"
Upvotes: 1