简体   繁体   中英

I need to scroll my Scroll view behind the relative layout( like overlay)

> This is my XML code, here i have coded the relative layout with a image which contains shadow in it and scroll view containing some other stuffs. I have to make my scroll view to scroll under the relative layout to get shadow effects."***

![have a look into the image at the bottom][1] ![

<?xml version="1.0" encoding="utf-8"?>
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/background"
            android:orientation="vertical" >

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="70dp"
                android:background="@drawable/bar_doubleline"
                android:paddingTop="10dp" >

                <Button
                    android:id="@+id/backtomemberdetailbtn"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_centerVertical="true"
                    android:background="#f7931d"
                    android:text="Back"
                    android:textColor="#ffffff"
                    android:textSize="18sp"
                    android:textStyle="bold" />

                <Button
                    android:id="@+id/membercardjoinbutton"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:layout_centerVertical="true"
                    android:background="#f7931d"
                    android:text="Join"
                    android:textColor="#ffffff"
                    android:textSize="20sp"
                    android:textStyle="bold" />

                <TextView
                    android:id="@+id/membercardtext"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerHorizontal="true"
                    android:layout_centerVertical="true"
                    android:text="Member Card"
                    android:textColor="#ffffff"
                    android:textSize="20sp"
                    android:textStyle="bold" />
            </RelativeLayout>

            <ScrollView
                android:id="@+id/scrollView1"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginTop="-3dp"
                android:fadingEdge="vertical" >

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical" >

                    <TableRow
                        android:id="@+id/tableRow1"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:gravity="center" >

                        <ImageView
                            android:id="@+id/imageView2"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="10dp"
                            android:layout_marginRight="10dp"
                            android:src="@drawable/card1" />
                    </TableRow>

                    <TextView
                        android:id="@+id/vmembercardtext"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginBottom="15dp"
                        android:layout_marginLeft="15dp"
                        android:layout_marginTop="10dp"
                        android:text=" Member card"
                        android:textAppearance="?android:attr/textAppearanceLarge"
                        android:textColor="#FFFFFF"
                        android:textSize="22sp"
                        android:textStyle="bold" />

                    <TextView
                        android:id="@+id/infotext"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginBottom="15dp"
                        android:layout_marginLeft="15dp"
                        android:layout_marginTop="10dp"
                        android:text="Company info"
                        android:textAppearance="?android:attr/textAppearanceMedium"
                        android:textColor="#FFFFFF"
                        android:textSize="22sp"
                        android:textStyle="bold" />

                    <TextView
                        android:id="@+id/descriptiontext"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginBottom="15dp"
                        android:layout_marginLeft="15dp"
                        android:layout_marginTop="10dp"
                        android:text="Description"
                        android:textAppearance="?android:attr/textAppearanceMedium"
                        android:textColor="#FFFFFF"
                        android:textSize="22sp"
                        android:textStyle="bold" />

                    <TableRow
                        android:id="@+id/tableRow2"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="70dp"
                        android:gravity="center" >

                        <Button
                            android:id="@+id/memberdetailbutton"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="10dp"
                            android:background="@drawable/start2"
                            android:text="view event"
                            android:textColor="#FFFF"
                            android:textSize="22dp"
                            android:textStyle="bold" />
                    </TableRow>
                </LinearLayout>
            </ScrollView>

        </LinearLayout>][1]


      [1]: http://i.stack.imgur.com/tmY8y.jpg


  [1]: http://i.stack.imgur.com/pXCzx.jpg

you can override the touch event for scroll and return false. Thus the event will not be consumed and will be passed to the view below it ie scrollView in your case. And it will work as it should even below your overlay layout.

This link will help You: How to transfer touch events to the view beneath in a RelativeLayout?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM