0

问题是我想让我的注册活动可滚动,但每当我启动应用程序时,我可以滚动但我无法查看下面的按钮。我试过把 alignParentTop = true 放在第一个edittext上。

这是我的代码:

 <LinearLayout>

      <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:orientation="vertical">
            <!-- Add CONi icon here -->

            <EditText
                android:id="@+id/editlastname"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="20sp"
                android:ems="10"
                android:hint="@string/lastname"
                android:inputType="textPersonName" />

        </LinearLayout>

    </ScrollView>

      <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:gravity="center|bottom"
        android:orientation="vertical">

       <Button
            android:id="@+id/btn_signup"
            style="@style/Widget.AppCompat.Button.Borderless"
            android:layout_width="200dp"
            android:layout_height="wrap_content"
            android:background="@drawable/round"
            android:text="@string/signup"
            android:textColor="@color/color3"
            android:layout_marginBottom="20dp"
            android:textSize="20sp" />
    </LinearLayout>

</LinearLayout>
4

2 回答 2

0

使用此 XML 代码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
tools:context=".MainActivity">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:orientation="vertical">
            <!-- Add CONi icon here -->

            <EditText
                android:id="@+id/editlastname"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="20sp"
                android:ems="10"
                android:hint="lastName"
                android:inputType="textPersonName" />

            <EditText
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="20sp"
                android:ems="10"
                android:hint="lastName"
                android:inputType="textPersonName" />

            <EditText
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="20sp"
                android:ems="10"
                android:hint="lastName"
                android:inputType="textPersonName" />

            <EditText
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="20sp"
                android:ems="10"
                android:hint="lastName"
                android:inputType="textPersonName" />

            <EditText
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="20sp"
                android:ems="10"
                android:hint="lastName"
                android:inputType="textPersonName" />

            <EditText
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="20sp"
                android:ems="10"
                android:hint="lastName"
                android:inputType="textPersonName" />

            <EditText
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="20sp"
                android:ems="10"
                android:hint="lastName"
                android:inputType="textPersonName" />

            <EditText
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="20sp"
                android:ems="10"
                android:hint="lastName"
                android:inputType="textPersonName" />

            <EditText
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="20sp"
                android:ems="10"
                android:hint="lastName"
                android:inputType="textPersonName" />

            <EditText
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="20sp"
                android:ems="10"
                android:hint="lastName"
                android:inputType="textPersonName" />

            <EditText
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="20sp"
                android:ems="10"
                android:hint="lastName"
                android:inputType="textPersonName" />

            <EditText
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="20sp"
                android:ems="10"
                android:hint="lastName"
                android:inputType="textPersonName" />

            <EditText
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="20sp"
                android:ems="10"
                android:hint="lastName"
                android:inputType="textPersonName" />

            <EditText
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="20sp"
                android:ems="10"
                android:hint="lastName"
                android:inputType="textPersonName" />

            <EditText
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="20sp"
                android:ems="10"
                android:hint="lastName"
                android:inputType="textPersonName" />

            <Button
                android:id="@+id/btn_signup"
                style="@style/Widget.AppCompat.Button.Borderless"
                android:layout_width="200dp"
                android:layout_height="wrap_content"
                android:text="signup"
                android:layout_marginBottom="20dp"
                android:textSize="20sp" />

        </LinearLayout>

    </ScrollView>

</LinearLayout>    
于 2019-02-07T14:12:44.527 回答
0

我对这个常见问题的解决方案是给最后一个视图/小部件一个“下边距”,如果问题仍然存在,请添加一个 marginTop 值。这对我有用,希望它也对你有用!

于 2020-08-03T02:15:47.470 回答