How to show controls in a fixed position for different screen resolutions in Android?

How to show controls in a fixed position for different screen resolutions in Android?

I have a screen design as 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 works in HVGA resolution (320x480), a progress indicator is displayed at the bottom of the screen, but if I run another resolution (WQVGA432 - 240x432), a progress indicator is displayed in the middle of the screen. I can not show it in a fixed position.

I use the manifest file showing below, but not the output

<supports-screens android:smallScreens="true"  
                android:normalScreens="true" 
                android:largeScreens="true"  
                android:anyDensity="true" />

I have no solution, so please give me some idea to solve the problem.

0
source share
3 answers

, , dip . :

android:layout_marginRight="10dip"

dip Device Independent Pixel, , Android , , , .

Android. , , dip, , .

+1

, : XML .

0

I would suggest that in the middle you have something like:

android:layout_gravity="center"

But yes, publishing your XML will be a little useful!

0
source

Source: https://habr.com/ru/post/1726430/


All Articles