4

我正在使用这个AndroidSlidingUpPanel

我的主要内容是 Map ,第二个上滑面板是 Recyclerview 。 但问题是它没有正确显示面板尺寸。

在折叠状态:它正确出现,但是一旦我向上拖动并 展开状态,它就会显示橙色条状的东西。橙色是由于线性布局中设置的背景,它是 RcycleView 的宿主。如果我们删除背景,那么问题也会出现在回收站视图列表末尾的条形图上。

我想要: Recycler 视图显示为与 Panel 相同的高度。它的末尾没有显示线性布局。

我认为我在 XML 中放置视图时做错了。但我无法理解是什么。

折叠的面板状态 在此处输入图像描述

扩展状态

在此处输入图像描述

主要的.xml

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

<com.sothree.slidinguppanel.SlidingUpPanelLayout
    xmlns:sothree="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/sliding_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="bottom"
    sothree:umanoShadowHeight="0dp"
    sothree:umanoDragView="@+id/dragView"
    sothree:umanoFadeColor="@android:color/transparent">


        <fragment
            android:id="@+id/map"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            class="com.google.android.gms.maps.SupportMapFragment"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height= "match_parent"
        android:background="#d35400"
        android:orientation="vertical"
        android:id="@+id/dragView">

        <android.support.v7.widget.RecyclerView
        android:id="@+id/path_recycler_view"
        android:layout_width="match_parent"
            android:orientation="vertical"
        android:layout_height="match_parent"
        android:clickable="true"
        android:focusable="false"
        xmlns:android="http://schemas.android.com/apk/res/android" />
        </LinearLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
    </RelativeLayout>

MainActivity.java

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_path_google_map);
        final SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map);
        googleMap = fm.getMap();
        mLayout = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout);
        FrameLayout fl = (FrameLayout) findViewById(R.id.list_fragment_container);
        recyclerView = (RecyclerView)findViewById(R.id.path_recycler_view);
         mMapCover = (View)findViewById(R.id.curtain_view);


ArrayList<MapHolders> holders = SingleTon.getInstance().getMapHolders();
        holders = SingleTon.getInstance().getMapHolders();
        if (holders != null && holders.size() > 0) {
            String url = getMapsApiDirectionsUrl();
            ReadTask downloadTask = new ReadTask();
            downloadTask.execute(url);

            googleMap.moveCamera(CameraUpdateFactory.newLatLng(holders.get(0).latLng));
            googleMap.animateCamera(CameraUpdateFactory.zoomTo(10));

            googleMap.setMyLocationEnabled(true);

               /*SlidingPanelUpLayout*/

            mLayout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN);



            addMarkers();

        }


        mLayout.setPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() {
            @Override
            public void onPanelSlide(View panel, final float slideOffset) {
                Log.i(TAG, "onPanelSlide, offset " + slideOffset);
                googleMap.getUiSettings().setAllGesturesEnabled(true);              

            }

            @Override
            public void onPanelExpanded(View panel) {
                Log.i(TAG, "onPanelExpanded");
                googleMap.getUiSettings().setAllGesturesEnabled(false);

            }

            @Override
            public void onPanelCollapsed(View panel) {
                slideFrag = true;
                Log.i(TAG, "onPanelCollapsed");
                googleMap.getUiSettings().setAllGesturesEnabled(false);

            }

            @Override
            public void onPanelAnchored(View panel) {
                Log.i(TAG, "onPanelAnchored");
            }

            @Override
            public void onPanelHidden(View panel) {
                slideFrag = false;
                Log.i(TAG, "onPanelHidden");
            }
        });

        mMapCover.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (mLayout.getPanelState() == SlidingUpPanelLayout.PanelState.COLLAPSED) {
                    mLayout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN);
                    return true;
                }

                return false;
            }
        });

    }

    private void addMarkers() {



        googleMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
            @Override
            public boolean onMarkerClick(Marker marker) {

                mLayout.setPanelHeight(400);


                    if(mLayout!=null){
                        Log.i("marker", "collapsed");
                        mLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
                        animateLatLngZoom(points, 0, -10, 10);

                    }else{
                        Log.i("marker","Hidden");
                        mLayout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN);
                    }
                }


                return true;
            }
        });




}

请帮我找出问题。

4

0 回答 0