Android的滚动型:底部按钮不显示

问题描述 投票:0回答:1

问题是,我想让我的注册活动滚动的,但每当我启动的应用程序,我可以滚动,但我不能查看下面的按钮。我试图把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>
android android-studio android-layout scrollview
1个回答
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>    
© www.soinside.com 2019 - 2024. All rights reserved.