Newbiee
Newbiee

Reputation: 592

bottom button covers part of scrollview

i am adding scrollview and a button at the bottom. the problem i am getting is my button hides last part of the scrollview. here is my xml code..

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

<ScrollView
    android:id="@+id/scroll_view"
    android:layout_width="match_parent"
    android:layout_height="fill_parent">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
 .
 .
 Code for some cardviews 
 .
 .  
 .
 .
</RelativeLayout>

</ScrollView>



    <Button
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:text="5000/-  CHECKOUT"
        android:textColor="@color/white"
        android:textSize="25dp"
        android:layout_alignParentBottom="true"
        android:background="@color/orange"/>



  </RelativeLayout>

the view i am getting is...enter image description here

here after personal trainer i have one more cardview for community members, which is not showing.. can anybody help me fix this?? Thanks in advance :)

Upvotes: 1

Views: 419

Answers (4)

Jeaux
Jeaux

Reputation: 23

change this

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

    <ScrollView
        android:id="@+id/scroll_view"
        android:layout_width="match_parent"
        android:layout_height="dp_of_your_choice">//need to try 300,400,500 and see how it works

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

         //.
         //.
         //Code for some cardviews 
         //.
         //.  
         //.
         //.
        </RelativeLayout>
    <scrollView>






<Button
    android:layout_width="match_parent"
    android:layout_height="60dp"
    android:text="5000/-  CHECKOUT"
    android:textColor="@color/white"
    android:textSize="25dp"
    android:layout_alignParentBottom="true"
    android:background="@color/orange"/>

Upvotes: 0

Faraz
Faraz

Reputation: 2154

Try this:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:background="@color/light_gray"
              android:orientation="vertical">

    <ScrollView
        android:id="@+id/scroll_view"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">
        <!-- Your card layout -->
    </ScrollView>

    <Button
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:layout_alignParentBottom="true"
        android:background="@color/orange"
        android:text="5000/-  CHECKOUT"
        android:textColor="@color/white"
        android:textSize="25dp"/>
</LinearLayout>

Upvotes: 0

Ravi
Ravi

Reputation: 35549

give id to your Button

<Button android:id="@+id/btn"
    android:layout_width="match_parent"
    ...

set your scrollView above Button

<ScrollView
    android:id="@+id/scroll_view"
    android:layout_above="@+id/btn"
    ...

Upvotes: 2

Anand Koshy
Anand Koshy

Reputation: 1

<Button
        android:layout_below="@+id/scroll_view"
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:text="5000/-  CHECKOUT"
        android:textColor="@color/white"
        android:textSize="25dp"
        android:layout_alignParentBottom="true"
        android:background="@color/orange"/> 

Try this out.

Upvotes: 0

Related Questions