【发布时间】:2017-11-28 13:42:15
【问题描述】:
我希望我的编辑按钮始终显示在屏幕底部。下面是我的代码。
<?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:padding="@dimen/dimen_16dp">
<Button
android:id="@+id/button_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:background="@color/colorPrimaryDark"
android:text="@string/edit"
android:textSize="20sp" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:layout_above="@+id/button_edit">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/til_name_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="16dp"
android:background="@drawable/register_layout_background"
android:clickable="false"
android:paddingBottom="16dp"
android:paddingTop="16dp">
<EditText
android:id="@+id/et_name_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:background="@color/transparent_color"
android:clickable="false"
android:gravity="center_vertical"
android:hint="@string/name"
android:inputType="textCapWords"
android:paddingTop="4dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/til_dob_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/til_name_view"
android:layout_marginBottom="8dp"
android:background="@drawable/register_layout_background"
android:clickable="false"
android:focusable="false"
android:paddingBottom="16dp"
android:paddingTop="16dp">
<EditText
android:id="@+id/et_dob_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:background="@color/transparent_color"
android:clickable="false"
android:focusable="false"
android:gravity="center_vertical"
android:hint="@string/date_of_birth"
android:inputType="date"
android:maxLength="10"
android:paddingTop="4dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/til_gender"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/til_dob_view"
android:layout_marginBottom="8dp"
android:background="@drawable/register_layout_background"
android:clickable="false"
android:focusable="false"
android:paddingBottom="16dp"
android:paddingTop="16dp">
<EditText
android:id="@+id/et_gender_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:background="@color/transparent_color"
android:clickable="false"
android:focusable="false"
android:gravity="center_vertical"
android:hint="@string/gender"
android:inputType="date"
android:maxLength="10"
android:paddingTop="4dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/til_address_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/til_gender"
android:layout_marginBottom="8dp"
android:background="@drawable/register_layout_background"
android:clickable="false"
android:paddingBottom="16dp"
android:paddingTop="16dp">
<EditText
android:id="@+id/et_address_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:background="@color/transparent_color"
android:clickable="false"
android:gravity="clip_vertical"
android:hint="@string/house_no_sector_street_phase_floor_etc"
android:inputType="textCapSentences"
android:paddingTop="4dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/til_pin_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/til_address_view"
android:layout_marginBottom="8dp"
android:background="@drawable/register_layout_background"
android:clickable="false"
android:paddingBottom="16dp"
android:paddingTop="16dp">
<EditText
android:id="@+id/et_pin_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:background="@color/transparent_color"
android:clickable="false"
android:gravity="center_vertical"
android:hint="@string/pin_code"
android:inputType="number"
android:maxLength="6"
android:paddingTop="4dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/til_state_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/til_pin_view"
android:layout_marginBottom="8dp"
android:background="@drawable/register_layout_background"
android:clickable="false"
android:paddingBottom="16dp"
android:paddingTop="16dp">
<EditText
android:id="@+id/et_state_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:background="@color/transparent_color"
android:clickable="false"
android:gravity="center_vertical"
android:hint="@string/state"
android:inputType="textCapWords"
android:paddingTop="4dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/til_contact_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/til_state_view"
android:layout_marginBottom="8dp"
android:background="@drawable/register_layout_background"
android:clickable="false"
android:paddingBottom="16dp"
android:paddingTop="16dp">
<EditText
android:id="@+id/et_contact_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:background="@color/transparent_color"
android:clickable="false"
android:gravity="center_vertical"
android:hint="@string/mobile_no"
android:inputType="number"
android:maxLength="10"
android:paddingTop="4dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/til_email_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/til_contact_view"
android:layout_marginBottom="8dp"
android:background="@drawable/register_layout_background"
android:clickable="false"
android:paddingBottom="16dp"
android:paddingTop="16dp">
<EditText
android:id="@+id/et_email_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:background="@color/transparent_color"
android:clickable="false"
android:focusable="false"
android:gravity="center_vertical"
android:hint="@string/e_mail"
android:inputType="textEmailAddress"
android:paddingTop="4dp" />
</android.support.design.widget.TextInputLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
问题:问题是按钮没有显示在底部,而是显示在屏幕的顶部,而且 ScrollView 根本不可见。如果我将外部 RelativeLayout 的 android:layout_height="match_parent" 中的 match_parent 更改为 500dp 之类的某个值,那么它可以正常工作,但是一旦我将其更改为 match_parent,按钮就会位于顶部。 谁能帮我找到需要纠正的地方?谢谢
【问题讨论】:
标签: android scrollview android-relativelayout