0

I have create android layout in layout folder my device inch is from 3.2 to 5 inch which comes under normal screen,targeting only this device only but my layout differ from each other in 3.2 and 4 inch.

Infinite Recursion
  • 6,511
  • 28
  • 39
  • 51
user3415586
  • 137
  • 1
  • 1
  • 8

4 Answers4

0

You can get the screen size problematically in java and make checks

Jaspreet Chhabra
  • 1,431
  • 15
  • 23
  • i am only targeting normal screen not small,large,they will be only normal screen...using webview,image and google advertisement in linearlayout 3.2 and 4 inch come under normal screen only – user3415586 Apr 23 '14 at 10:51
0

Follow that: Supporting multiple screen size - Android

Define your dimen values like that

res/values-sw600dp/dimen.xml -> 7+ inches
res/values-sw720dp/dimen.xml -> 10+ inches
values-w360dp
values-w500dp
values-w480dp
values-xlarge
values-v11
values-v14

Sherlock Bar check there

Community
  • 1
  • 1
Engr Waseem Arain
  • 1,163
  • 1
  • 17
  • 36
0
res/layout/my_layout.xml             // layout for normal screen size ("default")
res/layout-small/my_layout.xml       // layout for small screen size
res/layout-large/my_layout.xml       // layout for large screen size
res/layout-xlarge/my_layout.xml      // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation

res/drawable-mdpi/my_icon.png        // bitmap for medium density
res/drawable-hdpi/my_icon.png        // bitmap for high density
res/drawable-xhdpi/my_icon.png       // bitmap for extra high density
duggu
  • 37,851
  • 12
  • 116
  • 113
  • res/layout/my_layout.xml // layout for normal screen size ("default") i am using this layout only ,want to support from 3.2 inch to 4.7 inch put align change from each other – user3415586 Apr 23 '14 at 10:58
0

You need to create different folder for that

for example

layout folder/main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background"
android:orientation="vertical" >

<Button
    android:id="@+id/rate"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:text="Rate us"
    android:textColor="@color/black_font" />

</RelativeLayout>

layout-large/main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background"
android:orientation="vertical" >

<Button
    android:id="@+id/rate"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:text="Rate us"
    android:textColor="@color/black_font"
    android:textSize="30sp" />

</RelativeLayout>

layout-xlarge/main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background"
android:orientation="vertical" >

<Button
    android:id="@+id/rate"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:text="Rate us"
    android:textColor="@color/black_font"
    android:textSize="60sp" />

</RelativeLayout>

For further information see this link

For your problem you need to create it by Density

  1. ldpi Resources for low-density (ldpi) screens (~120dpi).
  2. mdpi Resources for medium-density (mdpi) screens (~160dpi). (This is the baseline density.)
  3. hdpi Resources for high-density (hdpi) screens (~240dpi).
  4. xhdpi Resources for extra high-density (xhdpi) screens (~320dpi).
  5. nodpi Resources for all densities. These are density-independent resources. The system does not scale resources tagged with this qualifier, regardless of the current screen's density.
  6. tvdpi Resources for screens somewhere between mdpi and hdpi; approximately 213dpi. This is not considered a "primary" density group. It is mostly intended for televisions and most apps shouldn't need it—providing mdpi and hdpi resources is sufficient for most apps and the system will scale them as appropriate. If you find it necessary to provide tvdpi resources, you should size them at a factor of 1.33*mdpi. For example, a 100px x 100px image for mdpi screens should be 133px x 133px for tvdpi.
Community
  • 1
  • 1
Shabbir Dhangot
  • 8,954
  • 10
  • 58
  • 80
  • res/layout/my_layout.xml // layout for normal screen size ("default")...between 3.2 to 4.7 inch comes under normal default layout only ..i am using imageview,webview,google add in linear layout – user3415586 Apr 23 '14 at 11:06