How do I show controls at a fixed position for various screen resolutions in Android?
I have a screen design like below
<?xml version="1.0" encoding="utf-8"?>
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:gravity="center_horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/img_background_loadbackground">
<TableRow>
<TextView
android:id="@+id/tv1"
android:layout_width="fill_parent"
android:layout_height="300sp"/>
</TableRow>
<TableRow>
</TableRow>
<ProgressBar
android:id="@+id/progressbar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</TableLayout>
It is working in HVGA(320×480) resolution, the progressbar appears at the bottom of the screen, but if I run in other resolution (WQVGA432 – 240×432) the progressbar appears in the middle of the screen. I am not able to show it in a fixed position.
I am using the manifest file show below but no output
<supports-screens android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:anyDensity="true" />
I don’t have a solution so please give me some idea to resolve the issue.
If you want your layouts to work on different resolution screens your should be sizing them using
dipas the unit. For example:dipstands for Device Independent Pixel and using these in your layout means that Android will automatically scale your layout depending on which display the device running your application has.You can read about these in the Supporting Multiple Screens page in the Android Developer Documentation. This document also has some other options for handling different displays but I think using
dipis probably the easiest.