在谷歌mapfragment细线滑动面板 - 向上滑动面板 [英] sliding up panel - thin line sliding panel under google mapfragment

查看:235
本文介绍了在谷歌mapfragment细线滑动面板 - 向上滑动面板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用这个库 https://github.com/dlukashev/AndroidSlidingUpPanel-四方 - 地图演示

但是,它包含未覆盖的任何地方一个bug被纠正。

在我接触的任何地方以扩大面板(列表视图)效果很好,但是当我试图按住地图(的FrameLayout)(画面3)在列表视图的顶部(在画面2蓝线)面板隐藏其展开

如何甚至有可能这个蓝色的线下mapfragment列表视图和其他部分隐藏面板展开呢?

任何想法,为什么?请给我只是一个提示如何解决?

请看屏幕:

 < XML版本=1.0编码=UTF-8&GT?;
< RelativeLayout的
    的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    的xmlns:程序=htt​​p://schemas.android.com/apk/res-auto
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =FILL_PARENT>

    < org.sothree.slidinguppanel.SlidingUpPanelLayout
        机器人:ID =@ + ID / slidingLayout
        机器人:重力=底
        应用程序:shadowHeight =0dp
        应用程序:paralaxOffset =@扪/ paralax_offset
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =FILL_PARENT>

        <的FrameLayout
            机器人:重力=顶
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =FILL_PARENT
            机器人:layout_below =@ + ID /按钮>

            < RelativeLayout的
                机器人:ID =@ + ID / mapContainer
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =497dp/>
        < /的FrameLayout>

        < RelativeLayout的
            机器人:ID =@ + ID / slidingContainer
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =FILL_PARENT
            机器人:layout_below =@ + ID /按钮>

            <查看
                机器人:ID =@ + ID / transparentView
                机器人:能见度=水涨船高
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =@扪/地图高度
                机器人:layout_alignParentTop =真/>

            <的ListView
                机器人:ID =@ + ID / ListView1的
                机器人:cacheColorHint =@机器人:彩色/白
                机器人:drawSelectorOnTop =真
                机器人:dividerHeight =@扪/ divider_height
                机器人:分隔=@机器人:彩色/ darker_gray
                机器人:背景=@机器人:彩色/透明
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =FILL_PARENT
                机器人:layout_below =@ ID / transparentView
                机器人:smoothScrollbar =真
                机器人:layout_marginTop =0dp/>

        < / RelativeLayout的>

    < /org.sothree.slidinguppanel.SlidingUpPanelLayout>

< / RelativeLayout的>
 

解决方案

您需要覆盖的ListView

 公共类LockableListView扩展的ListView {

私人布尔mScrollable = TRUE;

公共LockableListView(上下文的背景下){
    超(上下文);
}

公共LockableListView(上下文的背景下,ATTRS的AttributeSet){
    超(背景下,ATTRS);
}

公共LockableListView(上下文的背景下,ATTRS的AttributeSet,诠释defStyle){
    超(背景下,ATTRS,defStyle);
}

公共无效setScrollingEnabled(布尔启用){
    mScrollable =启用;
}

@覆盖
公共布尔的onTouchEvent(MotionEvent EV){
    开关(ev.getAction()){
        案例MotionEvent.ACTION_DOWN:
            //如果我们可以滚动的事件传递给超
            如果(mScrollable){
                返回super.onTouchEvent(EV);
            }
            //只有不断地处理触摸事件,如果滚动启用
            返回mScrollable; // mScrollable永远是假的,在这一点上
        默认:
            返回super.onTouchEvent(EV);
    }
}

@覆盖
公共布尔onInterceptTouchEvent(MotionEvent EV){
    //不要拦截触摸事件,如果做任何事情
    //我们不滚动
    如果(!mScrollable){
        返回false;
    } 其他 {
        返回super.onInterceptTouchEvent(EV);
    }
}
 

}

然后把禁用滚动需要时

 私人无效collapseMap(){
    mSpaceView.setVisibility(View.VISIBLE);
    mTransparentView.setVisibility(View.GONE);
    如果(MMAP = NULL和放大器;!&安培;!mLocation = NULL){
        mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(mLocation,11F),1000,NULL);
    }
    mListView.setScrollingEnabled(真正的);
}

私人无效expandMap(){
    mSpaceView.setVisibility(View.GONE);
    mTransparentView.setVisibility(View.INVISIBLE);
    如果(MMAP!= NULL){
        mMap.animateCamera(CameraUpdateFactory.zoomTo(14F),1000,NULL);
    }
    mListView.setScrollingEnabled(假);
}
 

我把这个变成GitHub的<一个href="https://github.com/dlukashev/AndroidSlidingUpPanel-foursquare-map-demo/commit/7b869394e9d197e6f56a833804426577dcb8458a" rel="nofollow">https://github.com/dlukashev/AndroidSlidingUpPanel-foursquare-map-demo/commit/7b869394e9d197e6f56a833804426577dcb8458a

享受

I made slidinguppanel using this repository https://github.com/dlukashev/AndroidSlidingUpPanel-foursquare-map-demo

However, it contains one bug which is not covered anywhere.

When I touch anywhere to expand panel (listview) works well, but while I'm trying to expand it by holding a top of a list view (blue line on screen2) panel hide under the map (framelayout) (screen3)

How it's even possible that this blue line hiding panel under mapfragment and rest of listview expand it well?

Any ideas why? Please give me just a hint how to fix it?

Please look at the screen:

<?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="fill_parent"
    android:layout_height="fill_parent">

    <org.sothree.slidinguppanel.SlidingUpPanelLayout
        android:id="@+id/slidingLayout"
        android:gravity="bottom"
        app:shadowHeight="0dp"
        app:paralaxOffset="@dimen/paralax_offset"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <FrameLayout
            android:gravity="top"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_below="@+id/button">

            <RelativeLayout
                android:id="@+id/mapContainer"
                android:layout_width="fill_parent"
                android:layout_height="497dp"/>
        </FrameLayout>

        <RelativeLayout
            android:id="@+id/slidingContainer"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_below="@+id/button">

            <View
                android:id="@+id/transparentView"
                android:visibility="gone"
                android:layout_width="fill_parent"
                android:layout_height="@dimen/map_height"
                android:layout_alignParentTop="true"/>

            <ListView
                android:id="@+id/listView1"
                android:cacheColorHint="@android:color/white"
                android:drawSelectorOnTop="true"
                android:dividerHeight="@dimen/divider_height"
                android:divider="@android:color/darker_gray"
                android:background="@android:color/transparent"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_below="@id/transparentView"
                android:smoothScrollbar="true"
                android:layout_marginTop="0dp"/>

        </RelativeLayout>

    </org.sothree.slidinguppanel.SlidingUpPanelLayout>

</RelativeLayout>

解决方案

You need to override ListView

public class LockableListView extends ListView {

private boolean mScrollable = true;

public LockableListView(Context context) {
    super(context);
}

public LockableListView(Context context, AttributeSet attrs) {
    super(context, attrs);
}

public LockableListView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
}

public void setScrollingEnabled(boolean enabled) {
    mScrollable = enabled;
}

@Override
public boolean onTouchEvent(MotionEvent ev) {
    switch (ev.getAction()) {
        case MotionEvent.ACTION_DOWN:
            // if we can scroll pass the event to the superclass
            if (mScrollable) {
                return super.onTouchEvent(ev);
            }
            // only continue to handle the touch event if scrolling enabled
            return mScrollable; // mScrollable is always false at this point
        default:
            return super.onTouchEvent(ev);
    }
}

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    // Don't do anything with intercepted touch events if
    // we are not scrollable
    if (!mScrollable) {
        return false;
    } else {
        return super.onInterceptTouchEvent(ev);
    }
}

}

Then put disable scrolling when needed

private void collapseMap() {
    mSpaceView.setVisibility(View.VISIBLE);
    mTransparentView.setVisibility(View.GONE);
    if (mMap != null && mLocation != null) {
        mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(mLocation, 11f), 1000, null);
    }
    mListView.setScrollingEnabled(true);
}

private void expandMap() {
    mSpaceView.setVisibility(View.GONE);
    mTransparentView.setVisibility(View.INVISIBLE);
    if (mMap != null) {
        mMap.animateCamera(CameraUpdateFactory.zoomTo(14f), 1000, null);
    }
    mListView.setScrollingEnabled(false);
}

I pushed this changes to GitHub https://github.com/dlukashev/AndroidSlidingUpPanel-foursquare-map-demo/commit/7b869394e9d197e6f56a833804426577dcb8458a

Enjoy

这篇关于在谷歌mapfragment细线滑动面板 - 向上滑动面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆