【问题标题】:sliding up panel - thin line sliding panel under google mapfragment向上滑动面板 - google mapfragment 下的细线滑动面板
【发布时间】:2015-09-06 06:21:35
【问题描述】:

我使用这个存储库https://github.com/dlukashev/AndroidSlidingUpPanel-foursquare-map-demo制作了滑动面板

但是,它包含一个未在任何地方涵盖的错误。

当我触摸任何地方以展开面板(列表视图)时效果很好,但是当我试图通过按住列表视图的顶部(屏幕 2 上的蓝线)来扩展它时,面板隐藏在地图下(框架布局)(屏幕 3)

mapfragment 和 listview 的其余部分下的这个蓝线隐藏面板怎么可能很好地展开它?

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

请看屏幕:

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

【问题讨论】:

  • 你能隐藏面板吗???
  • 我需要一些帮助.. 我看到了那个代码,但我没有隐藏滚动面板.. 我希望隐藏面板.. 当应用程序运行时它会从底部显示只有一行listview??

标签: android android-framelayout slidingmenu slidingpanelayout


【解决方案1】:

你需要重写 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);
    }
}

}

然后在需要时禁用滚动

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);
}

我将此更改推送到 GitHub https://github.com/dlukashev/AndroidSlidingUpPanel-foursquare-map-demo/commit/7b869394e9d197e6f56a833804426577dcb8458a

享受

【讨论】:

  • 非常感谢您的出色帮助!问题已解决!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多