Android 如何在面板外单击时隐藏Umano SlideingPanel
在这里,我使用的是Slidengup面板库。您可以在下面的屏幕中看到面板和列表视图。我试图做的是隐藏面板,如果我点击面板外(暗区)。而是在上面的布局中单击listview。我怎样才能做到这一点 这是XMLAndroid 如何在面板外单击时隐藏Umano SlideingPanel,android,android-sliding,slidingpanelayout,Android,Android Sliding,Slidingpanelayout,在这里,我使用的是Slidengup面板库。您可以在下面的屏幕中看到面板和列表视图。我试图做的是隐藏面板,如果我点击面板外(暗区)。而是在上面的布局中单击listview。我怎样才能做到这一点 这是XML <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://s
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.voucher.point.activity"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<!-- sothree:dragView="@+id/dragView" -->
<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:id="@+id/sliding_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="bottom"
app:fadeColor="@color/transparent"
sothree:panelHeight="40dip"
sothree:paralaxOffset="200dp" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/white"
android:orientation="vertical" >
<ListView
android:id="@+id/offersList"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="none"
android:visibility="gone" >
</ListView>
</LinearLayout>
<include
android:id="@+id/bottom_menu"
android:layout_width="fill_parent"
android:layout_height="270dip"
layout="@layout/side_menu" />
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
我可以这样做吗?您的幻灯片面板包含整个屏幕,然后您如何检测屏幕外的点击。如果你的目标是只为“HideMenu”和“ShowMenu”,那么这是可能的 否则,通过全屏滑动面板,您可以通过单击上一步android按钮或面板上的任何单击事件来隐藏它 如果我的回答不能解决您的问题,请告诉我
享受编码……:) 您可以将onClickListener或onTouchListener添加到外部面板和ontouch或OnClick调用slidingPanelLayout.expandPane(0)
我相信你已经解决了你的问题,但是对于其他有相同需求的人,我在我的地图上添加了另一个
视图
(在xml布局中),并设置了它的点击功能
因此,我的xml文件如下所示:
<com.sothree.slidinguppanel.SlidingUpPanelLayout
android:id="@+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/booking_confirm_layout"
android:gravity="bottom"
app:umanoFadeColor="@color/black_75_percent"
app:umanoOverlay="true"
app:umanoPanelHeight="111dp"
app:umanoShadowHeight="0dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.gms.maps.MapView
android:id="@+id/map_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="96dp" />
<View
android:id="@+id/mapCover"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"/>
</FrameLayout>
<LinearLayout>
.
.
.
</LinearLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
对于3.3.0及更高版本,可以通过以下方式实现
final SlidingUpPanelLayout slidingUpPanelLayout = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout);
slidingUpPanelLayout.setFadeOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
slidingUpPanelLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
}
});
完全隐藏它
mLayout.setFadeOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mLayout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN);
}
});
回答的代码对我不起作用。不幸的是,此事件没有捕获我的UI的一部分上的单击 为此,请为主要内容(SlidingUpPanelLayout的第一个子项)设置一个id,并将其称为:
findViewById(R.id.main_content).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(slidingUpPanelLayout.getPanelState() != SlidingUpPanelLayout.PanelState.COLLAPSED){
slidingUpPanelLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
}
}
});
嗨,我得到同样的问题,请分享如果你找到任何解决方案?嗨,Rethinavel Pillai,我需要这种实现。你能分享一下这个实现的核心代码吗?太好了!工作完美,但此侦听器忽略了滑动手势!!
//to hide when you touch overlay
mLayout.setFadeOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
}
});
mLayout.setFadeOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mLayout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN);
}
});
findViewById(R.id.main_content).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(slidingUpPanelLayout.getPanelState() != SlidingUpPanelLayout.PanelState.COLLAPSED){
slidingUpPanelLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
}
}
});