使用Scrollview,我无法将PROCEED按钮放在底部

时间:2019-05-04 16:27:28

标签: android xml layout

在以下情况下,我使用滚动视图遇到问题

案例1

当我不使用scrollview时,会得到this之类的布局,这是我需要的布局。 这种方法的问题是,当设备分辨率为412 x 732或更低时,由于这个原因,我无法看到布局的全部内容。我需要滚动视图

案例2

如果我使用滚动视图,则会得到像这样的视图thisthis分辨率1080x1920我得到this

对于更高分辨率的设备,案例2 中需要的内容是[PROCEED]按钮应使用bottomPadding = 20dp触摸底部,就像案例1 图片

如果有人给我建议以获取适用于高分辨率和低分辨率设备的布局,我真的很感激

布局

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    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:id="@+id/line"
            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:id="@+id/imageView"
            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_height="match_parent"

            android:layout_gravity="center"
            android:layout_marginTop="20dp"
            android:layout_marginBottom="20dp">

            <android.support.v7.widget.CardView
                android:layout_width="230dp"
                android:layout_height="@dimen/buttonHeight"

                android:layout_alignParentBottom="true"
                android:layout_centerHorizontal="true"
                app:cardBackgroundColor="@color/functionalityColor"
                app:cardCornerRadius="@dimen/cornerRadiusForButtons"

                app:cardElevation="@dimen/elevation">

                <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>

    </LinearLayout>

在布局中,我删除了滚动视图,并获得了适用于高分辨率设备的布局,但在低分辨率下,由于需要向下滚动,我无法看到全部内容

dimens.xml

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">

 <dimen name="design_navigation_icon_size" tools:override = "true" >30dp</dimen>


    // cornor radius for all button
    <dimen name="cornerRadiusForButtons">5dp</dimen>

    // cornor radius for all edit texts and text views and card views

    <dimen name="cornerRadiusForEdittexts">5dp</dimen>

    // elevation for cardView

    <dimen name="elevation">15dp</dimen>

    // this is the heading text size heading of all activities

    <dimen name="textSize">35sp</dimen>

    // used only once in userprofile below circleimageview

    <dimen name="belowHeadingSize">23sp</dimen>

    // this is the text that is present in the activity

    <dimen name="endSize">17sp</dimen>

    // button heights

    <dimen name="buttonHeight">50dp</dimen>




    // this is button text size

    <dimen name="buttonTextSizeMain">25sp</dimen>

    // donot know where does this use

    <dimen name="buttonTextSize">30sp</dimen>





    // width size of text view and edit texts

    <dimen name="widthEditText">290dp</dimen>

    // toolbar main title

    <dimen name="toolbarTitle">18sp</dimen>

    // toolbar subtitle

    <dimen name="toolbarSubtitle">14sp</dimen>


    // custom upper and lower cornors of the alert diloge etc


    <dimen name="customUpperLowerCorners">5dp</dimen>



</resources>

1 个答案:

答案 0 :(得分:0)

通过将此属性添加到“滚动视图”中,我的问题已解决

 android:fillViewport="true"