码迷,mamicode.com
首页 > 其他好文 > 详细

ScrollView cannot scroll in Slidinguppanellayout 解决办法

时间:2014-05-08 20:35:47      阅读:508      评论:0      收藏:0      [点我收藏+]

标签:android   style   blog   class   code   java   

bubuko.com,布布扣
xml源码如下
bubuko.com,布布扣
bubuko.com,布布扣
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white" >

    <com.sothree.slidinguppanel.SlidingUpPanelLayout
        xmlns:sothree="http://schemas.android.com/apk/res-auto"
        android:id="@+id/sliding_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="bottom"
        sothree:dragView="@+id/name"
        sothree:panelHeight="40dp"
        sothree:paralaxOffset="100dp"
        sothree:shadowHeight="4dp" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/white"
            android:orientation="vertical" >

            <RelativeLayout
                android:id="@+id/rel_top_layout"
                android:layout_width="fill_parent"
                android:layout_height="50dp"
                android:background="@color/t_blue" >

                <TextView
                    android:id="@+id/title_text_tv"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:text="统计图"
                    android:textColor="@color/white"
                    android:textSize="22sp" />

                <Button
                    android:id="@+id/btn_back"
                    android:layout_width="50dp"
                    android:layout_height="fill_parent"
                    android:layout_alignParentLeft="true"
                    android:layout_centerVertical="true"
                    android:background="@drawable/back_btn_selector" />
            </RelativeLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_margin="10dp"
                android:layout_weight="1"
                android:background="@drawable/border" >

                <LinearLayout
                    android:id="@+id/chart"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_margin="10dp"
                    android:orientation="vertical" >
                </LinearLayout>
            </LinearLayout>

            <RadioGroup
                android:id="@+id/radiogroup"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:orientation="horizontal" >

                <RadioButton
                    android:id="@+id/radio_histogram"
                    style="@style/param_text_style"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_margin="5dp"
                    android:layout_weight="1"
                    android:button="@drawable/radio_btn_selector"
                    android:onClick="changeGraph"
                    android:text="柱状图" />

                <RadioButton
                    android:id="@+id/radio_line_graph"
                    style="@style/param_text_style"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_margin="5dp"
                    android:layout_weight="1"
                    android:button="@drawable/radio_btn_selector"
                    android:onClick="changeGraph"
                    android:text="折线图" />
            </RadioGroup>
        </LinearLayout>

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

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:clickable="true"
                android:focusable="false"
                android:orientation="vertical" >

                <LinearLayout
                    android:id="@+id/drag"
                    android:layout_width="match_parent"
                    android:layout_height="40dp"
                    android:orientation="vertical" >

                    <ImageView
                        android:id="@+id/up"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:background="#1594df"
                        android:src="@drawable/icon_up"
                        android:visibility="visible" />

                    <ImageView
                        android:id="@+id/down"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:background="#1594df"
                        android:src="@drawable/icon_down"
                        android:visibility="gone" />
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/table_view"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:layout_marginRight="10dp"
                    android:orientation="vertical" >
                </LinearLayout>
            </LinearLayout>
        </ScrollView>
    </com.sothree.slidinguppanel.SlidingUpPanelLayout>

</RelativeLayout>
View Code

在Activity中

bubuko.com,布布扣
        slidingUpPanel.setDragView(findViewById(R.id.drag));
    // can‘t add this line
//        slidingUpPanel.setEnableDragViewTouchEvents(true);    
bubuko.com,布布扣

在com.sothree.slidinguppanel.SlidingUpPanelLayout中的onInterceptTouchEvent 处理 case MotionEvent.ACTION_DOWN:

bubuko.com,布布扣
    private boolean isDragViewHit(int x, int y) {
        if (isExpanded()) {
            // don‘t intercept touch if panel expanded
            return false;
        } else {
            // original implementation - only allow dragging on mDragView
            View v = mDragView != null ? mDragView : mSlideableView;
            if (v == null)
                return false;
            int[] viewLocation = new int[2];
            v.getLocationOnScreen(viewLocation);
            int[] parentLocation = new int[2];
            this.getLocationOnScreen(parentLocation);
            int screenX = parentLocation[0] + x;
            int screenY = parentLocation[1] + y;
            return screenX >= viewLocation[0] && screenX < viewLocation[0] + v.getWidth()
                    && screenY >= viewLocation[1] && screenY < viewLocation[1] + v.getHeight();
        }
    }
bubuko.com,布布扣

 

ScrollView cannot scroll in Slidinguppanellayout 解决办法,布布扣,bubuko.com

ScrollView cannot scroll in Slidinguppanellayout 解决办法

标签:android   style   blog   class   code   java   

原文地址:http://www.cnblogs.com/zhuqiang/p/3709495.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!