My items on large screen like 10.1 works fine and every item in its position but if I change the screen to 4 or 3, some of my items disappear and some appear in large font related to the device screen, so I want it to appear all items on its correct positions so if the app run on small screen the font small and every thing in its normal position, also with large screen. So what I have to do to my xml to get my goal?
this is my xml :
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="false"
android:fadingEdge="none"
android:background="#BFAF80"
android:scrollbars="none"
android:scrollbarSize="0dp"
android:paddingRight="0dp"
android:scrollbarAlwaysDrawVerticalTrack="false"
android:scrollbarStyle="insideOverlay"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#BFAF80"
android:id="@+id/CreatClear"
android:orientation="vertical">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="@+id/Bwt"
android:textStyle="bold"
android:gravity="center"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="29dp"
android:hint="@string/body_weight"
android:textColor="#e53f3f3f" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="@+id/Age"
android:textStyle="bold"
android:gravity="center"
android:hint="@string/age_years"
android:layout_below="@+id/Hit"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:textColor="#e53f3f3f" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="@+id/Screat"
android:gravity="center"
android:textStyle="bold"
android:hint="@string/serum_creatinine"
android:layout_below="@+id/Age"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:textColor="#e53f3f3f" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Female"
android:id="@+id/Cfemale"
android:textColor="#e53f3f3f"
android:textStyle="bold"
android:textSize="@dimen/abc_text_size_medium_material"
android:layout_marginTop="28dp"
android:layout_below="@+id/Screat"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Male"
android:id="@+id/Cmale"
android:textColor="#e53f3f3f"
android:textStyle="bold"
android:textSize="@dimen/abc_text_size_medium_material"
android:layout_below="@+id/Cfemale"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="64dp"
android:layout_height="64dp"
android:id="@+id/calcH"
android:background="@drawable/ic_launcher5"
android:clickable="false"
android:gravity="center"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="64dp"
android:layout_height="64dp"
android:id="@+id/calc"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="@drawable/ic_launcher"
android:clickable="true"
android:gravity="center" />
<TextView
android:layout_width="48dp"
android:layout_height="48dp"
android:text="Reset"
android:id="@+id/clearH"
android:textColor="#e53f3f3f"
android:textStyle="bold"
android:background="@drawable/ic_launcher5"
android:clickable="false"
android:gravity="center"
android:layout_alignBottom="@+id/sex"
android:layout_toLeftOf="@+id/sexa1"
android:layout_toStartOf="@+id/sexa1" />
<TextView
android:layout_width="48dp"
android:layout_height="48dp"
android:text="Reset"
android:id="@+id/clear"
android:textColor="#e53f3f3f"
android:textStyle="bold"
android:background="@drawable/ic_launcher3"
android:clickable="true"
android:gravity="center"
android:layout_alignTop="@+id/clearH"
android:layout_alignLeft="@+id/clearH"
android:layout_alignStart="@+id/clearH" />
<TextView
android:layout_width="48dp"
android:layout_height="48dp"
android:text="Menu"
android:id="@+id/menuH"
android:textColor="#e53f3f3f"
android:textStyle="bold"
android:background="@drawable/ic_launcher5"
android:clickable="false"
android:gravity="center"
android:layout_alignParentBottom="true"
android:layout_toRightOf="@+id/sex"
android:layout_toEndOf="@+id/sex" />
<TextView
android:layout_width="48dp"
android:layout_height="48dp"
android:text="Menu"
android:id="@+id/menu"
android:textColor="#e53f3f3f"
android:textStyle="bold"
android:background="@drawable/ic_launcher3"
android:clickable="true"
android:gravity="center"
android:layout_alignParentBottom="true"
android:layout_toRightOf="@+id/sex"
android:layout_toEndOf="@+id/sex" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="@+id/Hit"
android:textStyle="bold"
android:gravity="center"
android:hint="@string/height_cm"
android:layout_below="@+id/Bwt"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:textColor="#e53f3f3f"/>
<TextView
style="@style/TextAppearance.AppCompat.Medium"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/Serum"
android:gravity="center"
android:textColor="#e53f3f3f"
android:textStyle="bold"
android:textSize="@dimen/abc_text_size_large_material"
android:lines="@integer/abc_max_action_buttons"
android:autoText="false"
android:background="@color/ripple_material_dark"
android:layout_above="@+id/blank"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
style="@style/TextAppearance.AppCompat.Medium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/newSerum"
android:gravity="center"
android:textColor="#e53f3f3f"
android:textStyle="bold"
android:textSize="@dimen/abc_text_size_large_material"
android:layout_above="@+id/calcH"
android:layout_centerHorizontal="true"
android:visibility="visible"
android:lines="@integer/abc_max_action_buttons"
android:background="@color/ripple_material_dark" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="nIBW"
android:id="@+id/nIBW"
android:layout_below="@+id/Cmale"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="15dp"
android:layout_marginEnd="15dp"
android:layout_marginTop="34dp"
android:visibility="invisible" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="nABW"
android:id="@+id/nABW"
android:layout_alignBottom="@+id/nIBW"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:visibility="invisible" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="@+id/sex"
android:layout_alignTop="@+id/Cfemale"
android:layout_toRightOf="@+id/Screat"
android:layout_toEndOf="@+id/Screat"
android:gravity="center"
android:text="Gender"
android:visibility="invisible"
android:layout_alignParentLeft="true"
android:layout_marginLeft="0dp"
android:layout_alignParentTop="true"
android:layout_marginTop="604dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="@+id/sexa1"
android:gravity="center"
android:text="Gender1"
android:visibility="invisible"
android:layout_alignTop="@+id/Cfemale"
android:layout_alignRight="@+id/nIBW"
android:layout_alignEnd="@+id/nIBW" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="@+id/sexa2"
android:gravity="center"
android:text="Gender2"
android:visibility="invisible"
android:layout_alignTop="@+id/sexa1"
android:layout_alignRight="@+id/sexa1"
android:layout_alignEnd="@+id/sexa1" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="@+id/BSA"
android:gravity="center"
android:text="Body Surface Area"
android:visibility="invisible"
android:layout_below="@+id/Cmale"
android:layout_toLeftOf="@+id/nABW"
android:layout_toStartOf="@+id/nABW" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="@+id/blank"
android:layout_above="@+id/newSerum"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
style="@style/TextAppearance.AppCompat.Medium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Creat Clear (ml/min)"
android:id="@+id/HSerum"
android:gravity="center"
android:textColor="#ffffffff"
android:textStyle="bold"
android:background="@color/background_material_dark"
android:textSize="@dimen/abc_text_size_large_material"
android:layout_alignTop="@+id/BSA"
android:layout_toRightOf="@+id/Screat"
android:layout_toEndOf="@+id/Screat"
android:visibility="invisible" />
</RelativeLayout>
</ScrollView>
Create a some resource directories called values-swXXXdp in res folder where XXX means smallest screen witdh.
In each directory create a file called dimens.xml and define the dimension for each swXXXdp:
<dimen name="custom_width">40dp</dimen>
Then, to retrieve that value in xml do the following: for example the width of a view:
android:layout_width="@dimen/custom_width"