我正在使用此AndroidSlidingUpPanel。Umano中的Recycler視圖問題AndroidSlidingPanel
我的主要內容是地圖和第二個向上滑動面板是Recyclerview。 但問題是它不正確的面板大小。
在摺疊狀態:它的正確,但只要來我拖起來, 擴張狀態它顯示了在年底的橙色條類似的事情。橙色是由於在線性佈局中設置的背景,其中 是RcycleView的主機。如果我們刪除背景,那麼問題仍然存在。酒吧喜歡在回收站查看列表末尾。
我想要:Recycler視圖與Panel顯示的高度相同。在結尾沒有顯示線性佈局。
我想我在將視圖放入XML時出錯了。但我無法理解什麼。
膨脹狀態
main.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;
}
});
}
請幫我找到一個問題。
一個建議,爲了性能的緣故,刪除'RelativeLayout'或者如果您使用的是工具欄,並且爲了簡單起見沒有使用'FrameLayout'來代替它。我仍然不知道問題出在哪裏,但會看看這個問題。這只是現在:) – Hesam
只是爲了實驗,你可以設置滑動的高度(可以說600dp)。通過這種方式,如果你仍然看到橙色區域,那麼它會顯示你的代碼是錯誤的,這會給再循環視圖增加另一行。 – Hesam
@Hesam是的,它仍然會顯示橙色區域。在這也,如果看到mainactivity.java中的代碼,點擊標記點擊我已經設置panel.height = 400dp。它的展示。這同樣發生在任何高度組上。 –