Android 把按钮放在我最后一个屁股的底部
我很难将我的按钮与“登录密码”的底部对齐 我试过endOf,但它根本不起作用,在父对象的底部对齐,但似乎都不起作用。我尝试使用边距将其移动到底部,但它只是打破了用户名文本框。我遇到的问题有什么解决办法吗Android 把按钮放在我最后一个屁股的底部,android,android-layout,Android,Android Layout,我很难将我的按钮与“登录密码”的底部对齐 我试过endOf,但它根本不起作用,在父对象的底部对齐,但似乎都不起作用。我尝试使用边距将其移动到底部,但它只是打破了用户名文本框。我遇到的问题有什么解决办法吗 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://sch
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/myBlue"
android:orientation="vertical"
android:gravity="center"
tools:context="com.vice.jake.ric.fads.view.activites.MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:layout_toStartOf="@id/relativelayout1"
android:layout_marginBottom="275dp"
android:id="@+id/relativelayout1">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:src="@drawable/logov3_4" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerVertical="true"
android:id="@+id/relativelayout2">
<EditText
android:id="@+id/login_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:background="@drawable/luxx_edittext"
android:drawableStart="@drawable/ic_person_outline_black_24dp"
android:drawablePadding="15dp"
android:hint="Username"
android:padding="16dp" />
<EditText
android:id="@+id/login_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="112dp"
android:background="@drawable/luxx_edittext"
android:drawableStart="@drawable/ic_lock_outline_black_24dp"
android:drawablePadding="15dp"
android:hint="Password"
android:padding="16dp" />
<Button
android:id="@+id/button_redirect_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/holo_red_light"
android:layout_toEndOf="@id/login_password"
android:text="REGISTER"
android:textColor="@color/ghostWhiteColor" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Don't have an Account? Create one!"
android:textColor="@color/ghostWhiteColor"
android:layout_centerHorizontal="true"
android:padding="20dp"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
</RelativeLayout>
您可以使用
线性布局
而不是相对布局
您可以使用
线性布局
而不是相对布局
试试这个
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorAccent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginBottom="275dp"
android:src="@drawable/places_ic_search" />
<LinearLayout
android:id="@+id/relativelayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="vertical">
<EditText
android:id="@+id/login_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:background="@color/colorAccent"
android:drawablePadding="15dp"
android:drawableStart="@drawable/places_ic_clear"
android:hint="Username"
android:padding="16dp" />
<EditText
android:id="@+id/login_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:background="@color/colorPrimary"
android:drawablePadding="15dp"
android:drawableStart="@drawable/places_ic_clear"
android:hint="Password"
android:padding="16dp" />
<Button
android:id="@+id/button_redirect_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/login_password"
android:background="@color/colorAccent"
android:text="REGISTER"
android:textColor="#ff00" />
</LinearLayout>
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:padding="20dp"
android:text="Don't have an Account? Create one!"
android:textColor="#ff00" />
</RelativeLayout>
输出
试试这个
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorAccent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginBottom="275dp"
android:src="@drawable/places_ic_search" />
<LinearLayout
android:id="@+id/relativelayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="vertical">
<EditText
android:id="@+id/login_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:background="@color/colorAccent"
android:drawablePadding="15dp"
android:drawableStart="@drawable/places_ic_clear"
android:hint="Username"
android:padding="16dp" />
<EditText
android:id="@+id/login_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:background="@color/colorPrimary"
android:drawablePadding="15dp"
android:drawableStart="@drawable/places_ic_clear"
android:hint="Password"
android:padding="16dp" />
<Button
android:id="@+id/button_redirect_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/login_password"
android:background="@color/colorAccent"
android:text="REGISTER"
android:textColor="#ff00" />
</LinearLayout>
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:padding="20dp"
android:text="Don't have an Account? Create one!"
android:textColor="#ff00" />
</RelativeLayout>
输出
您可以使用android:layout\u-to-endof来代替
将此视图的上边缘定位在给定的定位点视图ID下方。
容纳此视图的上边缘和定位视图的下边缘
最后
<Button
android:id="@+id/button_redirect_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/holo_red_light"
android:layout_below="@id/login_password"
android:text="REGISTER"
android:textColor="@color/ghostWhiteColor" />
您可以使用android:layout\u-to-endof来代替
将此视图的上边缘定位在给定的定位点视图ID下方。
容纳此视图的上边缘和定位视图的下边缘
最后
<Button
android:id="@+id/button_redirect_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/holo_red_light"
android:layout_below="@id/login_password"
android:text="REGISTER"
android:textColor="@color/ghostWhiteColor" />
您应该使用下面的布局来对齐密码字段下面的按钮。我已经重新格式化了您的代码,添加了密码字段
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/lightBlue"
android:orientation="vertical"
android:gravity="center"
tools:context="com.vice.jake.ric.fads.view.activites.MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:layout_toStartOf="@id/relativelayout1"
android:layout_marginBottom="275dp"
android:id="@+id/relativelayout1">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:src="@drawable/ic_about" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerVertical="true"
android:id="@+id/relativelayout2">
<EditText
android:id="@+id/login_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:background="@drawable/luxx_edittext"
android:drawableStart="@drawable/ic_person_outline_black_24dp"
android:drawablePadding="15dp"
android:hint="Username"
android:padding="16dp" />
<EditText
android:id="@+id/login_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="112dp"
android:background="@drawable/luxx_edittext"
android:drawableStart="@drawable/ic_lock_outline_black_24dp"
android:drawablePadding="15dp"
android:hint="Password"
android:padding="16dp" />
<Button
android:id="@+id/button_redirect_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/holo_red_light"
android:layout_below="@id/login_password"
android:layout_marginTop="5dp"
android:text="REGISTER"
android:textColor="@color/ghostWhiteColor" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Don't have an Account? Create one!"
android:textColor="@color/ghostWhiteColor"
android:layout_centerHorizontal="true"
android:padding="20dp"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
</RelativeLayout>
您应该使用下面的布局来对齐密码字段下面的按钮。我已经重新格式化了您的代码,添加了密码字段
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/lightBlue"
android:orientation="vertical"
android:gravity="center"
tools:context="com.vice.jake.ric.fads.view.activites.MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:layout_toStartOf="@id/relativelayout1"
android:layout_marginBottom="275dp"
android:id="@+id/relativelayout1">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:src="@drawable/ic_about" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerVertical="true"
android:id="@+id/relativelayout2">
<EditText
android:id="@+id/login_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:background="@drawable/luxx_edittext"
android:drawableStart="@drawable/ic_person_outline_black_24dp"
android:drawablePadding="15dp"
android:hint="Username"
android:padding="16dp" />
<EditText
android:id="@+id/login_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="112dp"
android:background="@drawable/luxx_edittext"
android:drawableStart="@drawable/ic_lock_outline_black_24dp"
android:drawablePadding="15dp"
android:hint="Password"
android:padding="16dp" />
<Button
android:id="@+id/button_redirect_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/holo_red_light"
android:layout_below="@id/login_password"
android:layout_marginTop="5dp"
android:text="REGISTER"
android:textColor="@color/ghostWhiteColor" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Don't have an Account? Create one!"
android:textColor="@color/ghostWhiteColor"
android:layout_centerHorizontal="true"
android:padding="20dp"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
</RelativeLayout>
试试这个
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f6faf7"
android:gravity="center"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/relativelayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="275dp"
android:layout_toStartOf="@id/relativelayout1"
android:adjustViewBounds="true">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/relativelayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="vertical">
<EditText
android:id="@+id/login_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:drawablePadding="15dp"
android:hint="Username"
android:padding="16dp" />
<EditText
android:id="@+id/login_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="112dp"
android:drawablePadding="15dp"
android:hint="Password"
android:padding="16dp" />
<Button
android:id="@+id/button_redirect_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/login_password"
android:text="REGISTER" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:padding="20dp"
android:text="Don't have an Account? Create one!" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
你的输出是这样的。。
试试这个
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f6faf7"
android:gravity="center"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/relativelayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="275dp"
android:layout_toStartOf="@id/relativelayout1"
android:adjustViewBounds="true">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/relativelayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="vertical">
<EditText
android:id="@+id/login_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:drawablePadding="15dp"
android:hint="Username"
android:padding="16dp" />
<EditText
android:id="@+id/login_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="112dp"
android:drawablePadding="15dp"
android:hint="Password"
android:padding="16dp" />
<Button
android:id="@+id/button_redirect_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/login_password"
android:text="REGISTER" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:padding="20dp"
android:text="Don't have an Account? Create one!" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
你的输出是这样的。。
试试这个:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_relative"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/container_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/second_container_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/card_linearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="50dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:layout_toStartOf="@id/relativelayout1"
android:layout_marginBottom="275dp"
android:id="@+id/relativelayout1">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerVertical="true"
android:id="@+id/relativelayout2">
<EditText
android:id="@+id/login_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:background="@drawable/luxx_edittext"
android:drawableStart="@drawable/ic_person_outline_black_24dp"
android:drawablePadding="15dp"
android:hint="Username"
android:padding="16dp" />
<EditText
android:id="@+id/login_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:background="@drawable/luxx_edittext"
android:drawableStart="@drawable/ic_lock_outline_black_24dp"
android:drawablePadding="15dp"
android:hint="Password"
android:padding="16dp" />
<Button
android:id="@+id/button_redirect_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/holo_red_light"
android:layout_toEndOf="@id/login_password"
android:text="REGISTER"
android:textColor="@color/ghostWhiteColor" />
<TextView
android:layout_width="20dp"
android:layout_height="20dp" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
<RelativeLayout
android:id="@+id/pay_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Don't have an Account? Create one!"
android:textColor="@color/ghostWhiteColor"
android:layout_centerHorizontal="true"
android:padding="20dp"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
</RelativeLayout>
试试这个:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_relative"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/container_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/second_container_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/card_linearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="50dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:layout_toStartOf="@id/relativelayout1"
android:layout_marginBottom="275dp"
android:id="@+id/relativelayout1">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerVertical="true"
android:id="@+id/relativelayout2">
<EditText
android:id="@+id/login_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:background="@drawable/luxx_edittext"
android:drawableStart="@drawable/ic_person_outline_black_24dp"
android:drawablePadding="15dp"
android:hint="Username"
android:padding="16dp" />
<EditText
android:id="@+id/login_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:background="@drawable/luxx_edittext"
android:drawableStart="@drawable/ic_lock_outline_black_24dp"
android:drawablePadding="15dp"
android:hint="Password"
android:padding="16dp" />
<Button
android:id="@+id/button_redirect_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/holo_red_light"
android:layout_toEndOf="@id/login_password"
android:text="REGISTER"
android:textColor="@color/ghostWhiteColor" />
<TextView
android:layout_width="20dp"
android:layout_height="20dp" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
<RelativeLayout
android:id="@+id/pay_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Don't have an Account? Create one!"
android:textColor="@color/ghostWhiteColor"
android:layout_centerHorizontal="true"
android:padding="20dp"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
</RelativeLayout>
试试下面的XML代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/myBlue"
android:orientation="vertical"
android:gravity="center"
tools:context="com.vice.jake.ric.fads.view.activites.MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:layout_toStartOf="@id/relativelayout1"
android:layout_marginBottom="275dp"
android:id="@+id/relativelayout1">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:src="@drawable/logov3_4" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerVertical="true"
android:id="@+id/relativelayout2">
<EditText
android:id="@+id/login_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:background="@drawable/luxx_edittext"
android:drawableStart="@drawable/ic_person_outline_black_24dp"
android:drawablePadding="15dp"
android:hint="Username"
android:padding="16dp" />
<EditText
android:id="@+id/login_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="112dp"
android:background="@drawable/luxx_edittext"
android:drawableStart="@drawable/ic_lock_outline_black_24dp"
android:drawablePadding="15dp"
android:hint="Password"
android:padding="16dp" />
<Button
android:id="@+id/button_redirect_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/holo_red_light"
android:layout_below="@id/login_password"
android:text="REGISTER"
android:textColor="@color/ghostWhiteColor" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Don't have an Account? Create one!"
android:textColor="@color/ghostWhiteColor"
android:layout_centerHorizontal="true"
android:padding="20dp"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
</RelativeLayout>
您将得到低于输出的值
试试下面的XML代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/myBlue"
android:orientation="vertical"
android:gravity="center"
tools:context="com.vice.jake.ric.fads.view.activites.MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:layout_toStartOf="@id/relativelayout1"
android:layout_marginBottom="275dp"
android:id="@+id/relativelayout1">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:src="@drawable/logov3_4" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerVertical="true"
android:id="@+id/relativelayout2">
<EditText
android:id="@+id/login_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:background="@drawable/luxx_edittext"
android:drawableStart="@drawable/ic_person_outline_black_24dp"
android:drawablePadding="15dp"
android:hint="Username"
android:padding="16dp" />
<EditText
android:id="@+id/login_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="112dp"
android:background="@drawable/luxx_edittext"
android:drawableStart="@drawable/ic_lock_outline_black_24dp"
android:drawablePadding="15dp"
android:hint="Password"
android:padding="16dp" />
<Button
android:id="@+id/button_redirect_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/holo_red_light"
android:layout_below="@id/login_password"
android:text="REGISTER"
android:textColor="@color/ghostWhiteColor" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Don't have an Account? Create one!"
android:textColor="@color/ghostWhiteColor"
android:layout_centerHorizontal="true"
android:padding="20dp"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
</RelativeLayout>
您将得到低于输出的值
您正在将按钮与endOf对齐,endOf表示编辑文本的右侧。您必须在edittext布局下方对齐,如下所示
<Button
android:id="@+id/button_redirect_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/login_password"
android:text="REGISTER"
android:textColor="@color/ghostWhiteColor" />
因此,您应该能够看到登录密码下方的按钮您正在将按钮与endOf对齐,这意味着编辑文本的右侧。您必须在edittext布局下方对齐,如下所示
<Button
android:id="@+id/button_redirect_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/login_password"
android:text="REGISTER"
android:textColor="@color/ghostWhiteColor" />
Use Linear Layout(orientation- vertical) with weight when working for Login screen so that it fits fine to all the screen sizes
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/blue"
android:gravity="center"
android:orientation="vertical"
android:weightSum="10">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_alignParentTop="true"
android:layout_weight="2"
android:src="@drawable/logov3_4" />
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"></View>
<EditText
android:id="@+id/login_username"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@drawable/luxx_edittext"
android:drawableLeft="@drawable/ic_person_outline_black_24dp"
android:drawablePadding="15dp"
android:hint="Username"
android:padding="16dp" />
<EditText
android:id="@+id/login_password"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@drawable/luxx_edittext"
android:drawableLeft="@drawable/ic_lock_outline_black_24dp"
android:drawablePadding="15dp"
android:hint="Password"
android:padding="16dp" />
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"></View>
<Button
android:id="@+id/button_redirect_register"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@color/holo_red_light"
android:text="REGISTER"
android:textColor="@color/ghostWhiteColor" />
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"></View>
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:padding="20dp"
android:text="Don't have an Account? Create one!"
android:textColor="@color/ghostWhiteColor" />
</LinearLayout>
因此,在登录屏幕工作时,您应该能够看到登录密码下方的按钮使用带重量的线性布局(方向-垂直),以便适合所有屏幕大小
Use Linear Layout(orientation- vertical) with weight when working for Login screen so that it fits fine to all the screen sizes
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/blue"
android:gravity="center"
android:orientation="vertical"
android:weightSum="10">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_alignParentTop="true"
android:layout_weight="2"
android:src="@drawable/logov3_4" />
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"></View>
<EditText
android:id="@+id/login_username"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@drawable/luxx_edittext"
android:drawableLeft="@drawable/ic_person_outline_black_24dp"
android:drawablePadding="15dp"
android:hint="Username"
android:padding="16dp" />
<EditText
android:id="@+id/login_password"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@drawable/luxx_edittext"
android:drawableLeft="@drawable/ic_lock_outline_black_24dp"
android:drawablePadding="15dp"
android:hint="Password"
android:padding="16dp" />
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"></View>
<Button
android:id="@+id/button_redirect_register"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@color/holo_red_light"
android:text="REGISTER"
android:textColor="@color/ghostWhiteColor" />
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"></View>
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:padding="20dp"
android:text="Don't have an Account? Create one!"
android:textColor="@color/ghostWhiteColor" />
</LinearLayout>
在登录屏幕工作时,使用带重量的线性布局(方向-垂直),以便适合所有屏幕大小