1

In my application I've came over a simple registration activity, I am testing my application on sony xperia neo (480x854 3.7" ~265 ppi running 4.0 ics) and on samsung gio (320x480 3.2" ~180 ppi running 2.3.6 ginger )
it works very well on xperia but it's not on samsung (the layout margin doesnt apply i guess)
any idea about what's happening?

enter image description here enter image description here

here is my xml file

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <ImageView
        android:id="@+id/main_img_bg"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scaleType="fitXY"
        android:src="@drawable/bg" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="140dp"
        android:orientation="vertical" >

        <Spinner
            android:id="@+id/reg_spinner_country"
            android:layout_width="212dp"
            android:layout_height="44dp"
            android:layout_gravity="center"
            android:background="@drawable/spinner_bg"
            android:prompt="@string/country_prompt" />

        <Spinner
            android:id="@+id/reg_spinner_operator"
            android:layout_width="212dp"
            android:layout_height="44dp"
            android:layout_gravity="center"
            android:layout_marginTop="25dp"
            android:background="@drawable/spinner_bg"
            android:prompt="@string/operator_prompt" />

        <LinearLayout
            android:layout_width="212dp"
            android:layout_height="50dp"
            android:layout_gravity="center"
            android:layout_marginTop="25dp"
            android:layout_weight="0"
            android:background="@drawable/reg_layout_bg"
            android:padding="3dp" >

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="33dp"
                android:layout_gravity="center"
                android:layout_marginLeft="10dp"
                android:background="@color/white"
                android:padding="3dp" >

                <TextView
                    android:id="@+id/reg_text_operator_key"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="+96279"
                    android:textColor="@color/black" />
            </LinearLayout>

            <EditText
                android:id="@+id/reg_text_mobile_number"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="3dp"
                android:layout_marginRight="10dp"
                android:layout_marginTop="3dp"
                android:ems="7"
                android:inputType="phone" >
            </EditText>
        </LinearLayout>

        <ImageView
            android:id="@+id/reg_but_submit"
            android:layout_width="110dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="10dp"
            android:src="@drawable/btn_register"
            android:text="@string/submit_button" />
    </LinearLayout>

</FrameLayout>
4
  • 1
    Can i use form Relative Layout and Linear Layout or Frame Layout is to be used? Sep 24, 2013 at 12:03
  • 1
    I've tried it, by with RelativeLayout and it was fine in preview.
    – goodm
    Sep 24, 2013 at 12:04
  • most likely framelayout but I'll try a relative one Sep 24, 2013 at 12:45
  • perfect! post it in an answer so i can reward you :) Sep 24, 2013 at 12:48

1 Answer 1

1

Try This , I have tried this with Relative Layout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ImageView
        android:id="@+id/main_img_bg"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scaleType="fitXY"
        android:src="@drawable/ic_launcher" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:orientation="vertical" >

        <Spinner
            android:id="@+id/reg_spinner_country"
            android:layout_width="212dp"
            android:layout_height="44dp"
            android:layout_gravity="center"
            android:background="@drawable/spinner_bg"
            android:prompt="@string/country_prompt" />

        <Spinner
            android:id="@+id/reg_spinner_operator"
            android:layout_width="212dp"
            android:layout_height="44dp"
            android:layout_gravity="center"
            android:layout_marginTop="25dp"
            android:background="@drawable/spinner_bg"
            android:prompt="@string/operator_prompt" />

        <LinearLayout
            android:layout_width="212dp"
            android:layout_height="50dp"
            android:layout_gravity="center"
            android:layout_marginTop="25dp"
            android:layout_weight="0"
            android:background="@drawable/reg_layout_bg"
            android:padding="3dp" >

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="33dp"
                android:layout_gravity="center"
                android:layout_marginLeft="10dp"
                android:background="@color/white"
                android:padding="3dp" >

                <TextView
                    android:id="@+id/reg_text_operator_key"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="+96279"
                    android:textColor="@color/black" />
            </LinearLayout>

            <EditText
                android:id="@+id/reg_text_mobile_number"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="3dp"
                android:layout_marginRight="10dp"
                android:layout_marginTop="3dp"
                android:ems="7"
                android:inputType="phone" >
            </EditText>
        </LinearLayout>

        <ImageView
            android:id="@+id/reg_but_submit"
            android:layout_width="110dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="10dp"
            android:src="@drawable/btn_register"
            android:text="@string/submit_button" />
    </LinearLayout>

</RelativeLayout>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.