底部的ScrollView XML视图

时间:2019-03-15 13:50:14

标签: android xml android-layout

我试图将“继续”按钮置于底部,但它与底部不对齐。当我使用ScrollView时,会出现此问题,下面是XML和图像。我尝试了各种可能的方法,使“继续”按钮位于XML底部的ScrollView中。 如果我不包括 scrollView ,则布局将根据我的需要

screenshot

<?xml version="1.0" encoding="utf-8"?>
   <ScrollView android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/backgroundColor"
    xmlns:android="http://schemas.android.com/apk/res/android">

<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"
    android:orientation="vertical"
    android:background="@color/backgroundColor">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="USER AGREEMENT"
        android:textColor="@android:color/white"
        android:gravity="center"
        android:id="@+id/userAgereement"
        android:layout_marginTop="20dp"
        android:textSize="@dimen/textSize"/>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Beijing Pinnacle Global &amp; Alex Edu\n(BPGE &amp; Alex Edu)"
        android:textColor="@android:color/white"
        android:gravity="center"    
        android:layout_marginEnd="5dp"
        android:layout_marginStart="5dp"
        android:id="@+id/belowHeadingText"
        android:layout_marginTop="20dp"
        android:textSize="@dimen/endSize"/>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Today's Date : 25th of August, 2019"
        android:textColor="@android:color/white"
        android:gravity="center"
        android:layout_marginTop="20dp"
        android:id="@+id/date"
        android:textSize="@dimen/endSize"/>

    <View
        android:layout_width="270dp"
        android:layout_gravity="center"
        android:layout_marginTop="4dp"
        android:background="@android:color/white"
        android:layout_height="1dp">

    </View>    

    <ImageView
        android:layout_marginTop="20dp"
        android:layout_width="171dp"
        android:layout_height="239dp"
        android:layout_gravity="center"
        android:clickable="true"
        android:foreground="?attr/selectableItemBackgroundBorderless"
        android:src="@drawable/useragreemnet"/>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="You Are Going To Sign The User Agreement\nKindly, Provide Us Your Details"
        android:textColor="@android:color/white"
        android:gravity="center"
        android:id="@+id/belowImageText"
        android:layout_marginTop="20dp"
        android:textSize="@dimen/endSize"/>    

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_marginTop="20dp"
        android:layout_marginBottom="20dp"
        android:layout_gravity="center"
        android:layout_height="match_parent">  

        <android.support.v7.widget.CardView
            android:layout_width="230dp"    
            app:cardElevation="@dimen/elevation"
            app:cardCornerRadius="@dimen/cornerRadiusForButtons"
            app:cardBackgroundColor="@color/functionalityColor"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="20dp"
            android:layout_height="@dimen/buttonHeight">

            <Button    
                android:gravity="center"
                android:layout_width="match_parent"
                android:layout_height="@dimen/buttonHeight"
                android:clickable="true"
                android:foreground="?attr/selectableItemBackgroundBorderless"
                android:id="@+id/proceed"
                android:text="PROCEED"
                android:onClick="onClick"
                android:textSize="@dimen/buttonTextSize"
                android:textColor="@android:color/white"
                android:background="@android:color/transparent" 
                android:layout_marginBottom="20dp"/>
         </android.support.v7.widget.CardView>        

    </RelativeLayout>

</LinearLayout>        

</ScrollView>

1 个答案:

答案 0 :(得分:0)

  

在布局文件中使用此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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/backgroundColor">

        <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"
            android:background="@color/backgroundColor"
            android:orientation="vertical">


            <TextView
                android:id="@+id/userAgereement"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp"
                android:gravity="center"
                android:text="USER AGREEMENT"
                android:textColor="@android:color/white"
                android:textSize="@dimen/textSize" />

            <TextView
                android:id="@+id/belowHeadingText"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginStart="5dp"
                android:layout_marginTop="20dp"

                android:layout_marginEnd="5dp"
                android:gravity="center"
                android:text="Beijing Pinnacle Global &amp; Alex Edu\n(BPGE &amp; Alex Edu)"
                android:textColor="@android:color/white"
                android:textSize="@dimen/endSize" />


            <TextView
                android:id="@+id/date"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp"
                android:gravity="center"
                android:text="Today's Date : 25th of August, 2019"
                android:textColor="@android:color/white"
                android:textSize="@dimen/endSize" />

            <View
                android:layout_width="270dp"
                android:layout_height="1dp"
                android:layout_gravity="center"
                android:layout_marginTop="4dp"
                android:background="@android:color/white">

            </View>


            <ImageView
                android:layout_width="171dp"
                android:layout_height="239dp"
                android:layout_gravity="center"
                android:layout_marginTop="20dp"
                android:clickable="true"
                android:foreground="?attr/selectableItemBackgroundBorderless"
                android:src="@drawable/useragreemnet"

                />

            <TextView
                android:id="@+id/belowImageText"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp"
                android:gravity="center"
                android:text="You Are Going To Sign The User Agreement\nKindly, Provide Us Your Details"
                android:textColor="@android:color/white"
                android:textSize="@dimen/endSize" />


        </LinearLayout>


    </ScrollView>

    <android.support.design.widget.BottomNavigationView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:orientation="vertical">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:layout_marginTop="20dp"
            android:layout_marginBottom="20dp">

            <android.support.v7.widget.CardView
                app:cardBackgroundColor="@color/functionalityColor"

                app:cardCornerRadius="@dimen/cornerRadiusForButtons"
                app:cardElevation="@dimen/elevation"
                android:layout_width="230dp"
                android:layout_height="@dimen/buttonHeight"
                android:layout_alignParentBottom="true"
                android:layout_centerHorizontal="true"

                android:layout_marginBottom="20dp">

                <Button

                    android:id="@+id/proceed"
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/buttonHeight"
                    android:layout_marginBottom="20dp"
                    android:background="@android:color/transparent"
                    android:clickable="true"
                    android:foreground="?attr/selectableItemBackgroundBorderless"
                    android:gravity="center"
                    android:onClick="onClick"
                    android:text="PROCEED"
                    android:textColor="@android:color/white"
                    android:textSize="@dimen/buttonTextSize" />

            </android.support.v7.widget.CardView>


        </RelativeLayout>

    </android.support.design.widget.BottomNavigationView>
</RelativeLayout>