1

I tried to use different xml files depending on screen size by putting them in different folders, layout-small, layout-normall, layout-larg, layout-xlarg.

My Galaxy tablet is using the layout in layout-large, but my vergin phone and Galaxy phone are getting the layout in layout-normal folder.

does Google pick the layouts base on screen size, not screen resolution? also in setting the font size I'm using dp, which I thought was dots per inch. But on the vergin phone the text is really big, and on the galaxy its almost to small to read.

xml file

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"

       android:orientation="vertical"
        android:background="#005F5F5F"

     >


  <LinearLayout
    android:id="@+id/linearLayout"  
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:orientation="vertical">


        <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Layout-normal"
                android:layout_gravity="center"
                android:textColor="#ff000000"
                android:textStyle="bold"

                 /> </LinearLayout>      



    <ScrollView 
    android:layout_height="fill_parent" 
    android:layout_width="fill_parent">    

         <LinearLayout

  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:layout_gravity="center_vertical"
  android:orientation="vertical">

                <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="BitcoinDark"
                android:layout_gravity="center"
                android:textColor="#ff000000"
                android:textStyle="bold"
                android:textSize="20px"
                 />

                <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Values Provided By Bittrex"
                android:layout_gravity="center"
                android:textColor="#ff000000"
                android:textStyle="bold"
                android:textSize="20px"
                 />             

              <ImageView                    
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/icon"
            android:id="@+id/fred"  
            android:layout_gravity="center"
            android:layout_marginTop="12px" 
        />   



  <LinearLayout
  android:layout_gravity="center"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:orientation="horizontal">

<TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="High"
                android:layout_gravity="center"
                android:textColor="#ff000000"
                android:textStyle="bold"
                android:textSize="20px"
                 />

            <TextView
                android:id="@+id/textHigh"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Value"
                android:layout_gravity="center"
                android:textColor="#ff000000"
                android:textStyle="bold"
                android:textSize="20px"
                android:layout_marginLeft="12px"
                 />     


</LinearLayout> 

    <LinearLayout
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_gravity="center"
  android:orientation="horizontal">                               

   <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Low"
                android:layout_gravity="center"
                android:textColor="#ff000000"
                android:textStyle="bold"
                android:textSize="20px"

                 />

            <TextView
                android:id="@+id/textLowest"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Value"
                android:layout_gravity="center"
                android:textColor="#ff000000"
                android:textStyle="bold"
                android:textSize="20px"
                android:layout_marginLeft="12px"
                 />                   
      </LinearLayout>

      <LinearLayout
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_gravity="center"
  android:orientation="horizontal">


            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Volume"
                android:textColor="#ff000000"
                android:textStyle="bold"
                android:textSize="20px"
                 />

            <TextView
                android:id="@+id/textVol"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Value"
                android:textColor="#ff000000"
                android:textStyle="bold"
                android:layout_marginLeft="12px"    
                android:textSize="20px"
                 />         
   </LinearLayout>  

      <Button
          android:id="@+id/butRef"
       android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="24px"
      android:text="Refresh"
      android:textColor="#ff000000"
      android:layout_gravity="center"
        android:layout_marginTop="12px"
      />    

      </LinearLayout> 
      </ScrollView>
      </LinearLayout> 
yassine__
  • 393
  • 4
  • 15
Ted pottel
  • 6,869
  • 21
  • 75
  • 134

1 Answers1

0

px is one pixel. sp is scale-independent pixels. dip is Density-independent pixels. You would use

sp for font sizes

dip for everything else.

dip==dp

px
Pixels - corresponds to actual pixels on the screen.

in
Inches - based on the physical size of the screen.

mm
Millimeters - based on the physical size of the screen.

pt
Points - 1/72 of an inch based on the physical size of the screen.

dp
Density-independent Pixels - an abstract unit that is based on the physical density of the   
screen. These units are relative to a 160 dpi screen, so one dp is one pixel on a 160 dpi screen.
The ratio of dp-to-pixel will change with the screen density, but not necessarily in direct  
proportion. Note: The compiler accepts both "dip" and "dp", though "dp" is more consistent with 
"sp".

sp
Scale-independent Pixels - this is like the dp unit, but it is also scaled by the user's font 
size preference. It is recommend you use this unit when specifying font sizes, so they will be 
adjusted for both the screen density and user's preference.

Refrence

Community
  • 1
  • 1
Kushal Sharma
  • 5,978
  • 5
  • 25
  • 41