所以我在一个活动中有一个简单的片段,可以在某些设备上正确呈现,但在其他设备上,组件会被移动。
这就是布局应该是什么样的(三星s4,s5):
但这是在某些设备上发生的事情(星系说明):
layout.xml:
<?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"
android:background="#ffffff"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.design.widget.TextInputLayout
android:id="@+id/personName_su_il"
android:layout_width="wrap_content"
android:layout_height="45dp"
app:errorEnabled="true"
app:errorTextAppearance="@style/ErrorText"
app:hintAnimationEnabled="true"
android:hint="Full Name"
>
<EditText
android:singleLine="true"
android:imeOptions="actionGo"
android:layout_width="180dp"
android:layout_height="40dp"
android:background="@drawable/round_corners_dark"
android:id="@+id/personName_su"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/companyName_su_il"
android:layout_width="wrap_content"
android:layout_height="45dp"
app:errorEnabled="true"
app:errorTextAppearance="@style/ErrorText"
app:hintAnimationEnabled="true"
android:hint="Company Name"
android:layout_below="@+id/personName_su_il"
>
<EditText
android:singleLine="true"
android:imeOptions="actionGo"
android:layout_width="230dp"
android:layout_height="40dp"
android:background="@drawable/round_corners_dark"
android:id="@+id/companyName_su"
android:layout_below="@+id/personName_su_il"
android:layout_centerHorizontal="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/phoneNumber_su_il"
android:layout_width="wrap_content"
android:layout_height="45dp"
app:errorEnabled="true"
app:errorTextAppearance="@style/ErrorText"
app:hintAnimationEnabled="true"
android:hint="Phone Number"
android:layout_below="@+id/companyName_su_il"
>
<EditText
android:singleLine="true"
android:imeOptions="actionGo"
android:layout_width="230dp"
android:layout_height="40dp"
android:background="@drawable/round_corners_dark"
android:id="@+id/phoneNumber_su"
android:layout_below="@+id/companyName_su_il"
android:layout_centerHorizontal="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/physicalAddress_su_il"
android:layout_width="wrap_content"
android:layout_height="45dp"
app:errorEnabled="true"
app:errorTextAppearance="@style/ErrorText"
app:hintAnimationEnabled="true"
android:hint="Physical Address"
android:layout_below="@+id/phoneNumber_su_il"
>
<EditText
android:singleLine="true"
android:imeOptions="actionGo"
android:layout_width="230dp"
android:layout_height="40dp"
android:background="@drawable/round_corners_dark"
android:id="@+id/physicalAddress_su"
android:layout_below="@+id/phoneNumber_su_il"
android:layout_centerHorizontal="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/hourlyRate_su_il"
android:layout_width="wrap_content"
android:layout_height="45dp"
app:errorEnabled="true"
app:errorTextAppearance="@style/ErrorText"
app:hintAnimationEnabled="true"
android:hint="Hourly Rate(Digits Only)(Optional)"
android:layout_below="@+id/physicalAddress_su_il"
>
<EditText
android:singleLine="true"
android:imeOptions="actionGo"
android:layout_width="230dp"
android:layout_height="40dp"
android:background="@drawable/round_corners_dark"
android:id="@+id/hourlyRate_su"
android:layout_below="@+id/physicalAddress_su_il"
android:layout_centerHorizontal="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/emailAddress_su_il"
android:layout_width="wrap_content"
android:layout_height="45dp"
app:errorEnabled="true"
app:errorTextAppearance="@style/ErrorText"
app:hintAnimationEnabled="true"
android:hint="Email Address"
android:layout_below="@+id/hourlyRate_su_il"
>
<EditText
android:singleLine="true"
android:imeOptions="actionGo"
android:layout_width="230dp"
android:layout_height="40dp"
android:background="@drawable/round_corners_dark"
android:id="@+id/emailAddress_su"
android:layout_below="@+id/hourlyRate_su_il"
android:layout_centerHorizontal="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/password_su_il"
android:layout_width="wrap_content"
android:layout_height="45dp"
app:errorEnabled="true"
app:errorTextAppearance="@style/ErrorText"
app:hintAnimationEnabled="true"
android:hint="Password"
android:layout_below="@+id/emailAddress_su_il"
>
<EditText
android:inputType="textPassword"
android:singleLine="true"
android:imeOptions="actionGo"
android:layout_width="230dp"
android:layout_height="40dp"
android:background="@drawable/round_corners_dark"
android:id="@+id/password_su"
android:layout_below="@+id/emailAddress_su_il"
android:layout_centerHorizontal="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/activation_code_su_il"
android:layout_width="wrap_content"
android:layout_height="45dp"
app:errorEnabled="true"
app:errorTextAppearance="@style/ErrorText"
app:hintAnimationEnabled="true"
android:hint="Activation Code"
android:layout_below="@+id/password_su_il"
>
<EditText
android:inputType="textPassword"
android:singleLine="true"
android:imeOptions="actionGo"
android:layout_width="230dp"
android:layout_height="40dp"
android:background="@drawable/round_corners_dark"
android:id="@+id/activation_code_su"
android:layout_below="@+id/password_su_il"
android:layout_centerHorizontal="true" />
</android.support.design.widget.TextInputLayout>
<Button
android:layout_width="150dp"
android:layout_height="wrap_content"
android:text="profilePicture"
android:textAllCaps="false"
android:textSize="18dp"
android:background="@drawable/round_corners_list"
android:textColor="#f7f7f7"
android:id="@+id/uploadProPicButton_su"
android:layout_below="@+id/chosenCategories"
android:layout_centerHorizontal="true" />
<ImageView
android:layout_width="60dp"
android:layout_height="80dp"
android:id="@+id/proPicThumbnail"
android:scaleType="fitXY"
android:background="#ffffff"
android:layout_above="@+id/signUpButton_su"
android:layout_toEndOf="@+id/signUpButton_su" />
<Spinner
android:layout_width="100dp"
android:layout_height="40dp"
android:id="@+id/serviceCategory_su"
android:background="@drawable/round_corners_dark"
android:layout_above="@+id/companyName_su_il"
android:layout_alignParentEnd="true"
android:layout_toEndOf="@+id/personName_su_il"
android:layout_marginLeft="2dp"
android:layout_alignStart="@+id/townSpinner" />
<Button
android:layout_width="250dp"
android:layout_height="40dp"
android:text="register"
android:textSize="18dp"
android:background="@drawable/round_corners_list"
android:textAllCaps="false"
android:textColor="#f7f7f7"
android:id="@+id/signUpButton_su"
android:layout_below="@+id/uploadProPicButton_su"
android:layout_centerHorizontal="true"
android:layout_marginTop="7dp" />
<ImageView
android:layout_width="40dp"
android:layout_height="wrap_content"
android:id="@+id/viewPasswordButton"
android:src="@mipmap/view_icon"
android:layout_marginBottom="3dp"
android:layout_alignBottom="@+id/password_su_il"
android:layout_toEndOf="@+id/password_su_il" />
<Spinner
android:layout_width="150dp"
android:layout_height="40dp"
android:id="@+id/countrySpinner"
android:background="@drawable/round_corners_dark"
android:layout_alignBottom="@+id/companyName_su_il"
android:layout_alignParentEnd="true"
android:layout_alignStart="@+id/serviceCategory_su" />
<Spinner
android:layout_width="150dp"
android:layout_height="40dp"
android:id="@+id/townSpinner"
android:background="@drawable/round_corners_dark"
android:layout_alignBottom="@+id/phoneNumber_su_il"
android:layout_alignParentEnd="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/chosenCategories"
android:textSize="16dp"
android:textColor="#484848"
android:background="@drawable/round_corners_dark"
android:layout_below="@+id/activation_code_su_il"
android:layout_centerHorizontal="true"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text"
android:id="@+id/termsAndConditions"
android:textSize="12dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>