Frage

I'm having a display problem for my android application which I made. when I try my application on Samsung grand1 and S3-mini it works fine like the emulator. but when I try it on Samsung S3 some buttons and textviews get shifted down. so is there any way to make sure that all the elements of the layout stays in the same position for all devices ?

and this is my layout xml file for the main activity

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg123"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<Button
    android:id="@+id/clrthis"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:layout_marginBottom="171dp"
    android:text="تصفير الحالي"
    android:textSize="10sp" />

<FrameLayout
    android:id="@+id/frameLayout1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >
</FrameLayout>

<TextView
    android:id="@+id/CounterTxtview"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/clrthis"
    android:layout_toLeftOf="@+id/clrthis"
    android:layout_toRightOf="@+id/clrall"
    android:gravity="center"
    android:text="1"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textColor="@color/tvcc"
    android:textSize="@dimen/tvc" />

<Spinner
    android:id="@+id/Chsp"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/clrthis"
    android:layout_alignLeft="@+id/clrall"
     android:gravity="center"
    android:layout_marginBottom="56dp" />

<Button
    android:id="@+id/b1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:layout_marginTop="63dp"
    android:layout_toRightOf="@+id/frameLayout1"
    android:text="Button"
     />

<Button
    android:id="@+id/clrall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/frameLayout1"
    android:layout_alignTop="@+id/CounterTxtview"
    android:text="  تصفير الكل "
    android:textSize="10dp" />

</RelativeLayout>
War es hilfreich?

Lösung

The components fit when there is not enough space for them on the screen. You can create different layouts for your application, depending on the screen size. To do that create different xml's and put in folders (drawable-ldpi, mdpi, hdpi, xhdpi, xxhdpi) separate from your project. Or, change the positioning of its components.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top