New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to hide the Umano SlidingupPanel when clicking outside the panel #476
Comments
Any solution on this? |
@sergiomarquesmoura <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".DemoActivity" >
<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:id="@+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:umanoPanelHeight="68dp"
sothree:umanoShadowHeight="4dp"
sothree:umanoParallaxOffset="100dp"
sothree:umanoDragView="@+id/dragView"
sothree:umanoOverlay="true"
sothree:umanoScrollableView="@+id/list">
<!-- MAIN CONTENT -->
<RalativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
..... content ..........
</FrameLayout>
<View
android:id="@+id/curtain_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:background="@android:color/transparent"/>
</RalativeLayout>
<!-- SLIDING LAYOUT -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="vertical"
android:clickable="true"
android:focusable="false"
android:id="@+id/dragView">
</LinearLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
</RelativeLayout> Next you can catch SlidingUpPanelLayout.PanelSlideListener events and set visibility for curtain_view . Then you can set onClickListener for curtain_view . In this listener you can shut down SlidingUpPanel or do what you want : slidingUpPanel.setPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() {
@Override
public void onPanelSlide(View panel, float slideOffset) {
Log.i("SlidingUpPanel", "onPanelSlide, offset " + slideOffset);
curtain_view.setVisibility(View.VISIBLE);
}
@Override
public void onPanelExpanded(View panel) {
Log.i("SlidingUpPanel", "onPanelExpanded");
curtain_view.setVisibility(View.VISIBLE);
}
@Override
public void onPanelCollapsed(View panel) {
Log.i("SlidingUpPanel", "onPanelCollapsed");;
curtain_view.setVisibility(View.INVISIBLE);
}
@Override
public void onPanelAnchored(View panel) {
Log.i("SlidingUpPanel", "onPanelAnchored");
curtain_view.setVisibility(View.VISIBLE);
}
@Override
public void onPanelHidden(View panel) {
Log.i("SlidingUpPanel", "onPanelHidden");
curtain_view.setVisibility(View.INVISIBLE);
}
}); |
set the panel height to zero and on click change it to 50dp |
check issue #458 |
There an easy workaround. For the main content view, i.e. the first view of the public class SlidingAwareLinearLayout extends LinearLayout {
public SlidingAwareLinearLayout(final Context context) {
super(context);
}
public SlidingAwareLinearLayout(final Context context, final AttributeSet attrs) {
super(context, attrs);
}
public SlidingAwareLinearLayout(
final Context context, final AttributeSet attrs, final int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public SlidingAwareLinearLayout(
final Context context, final AttributeSet attrs, final int defStyleAttr,
final int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
@Override
public boolean onInterceptTouchEvent(final MotionEvent ev) {
SlidingUpPanelLayout panel = (SlidingUpPanelLayout) getParent();
if (ev.getAction() == MotionEvent.ACTION_DOWN
&& panel.getPanelState() == SlidingUpPanelLayout.PanelState.ANCHORED) {
panel.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
return true;
}
return super.onInterceptTouchEvent(ev);
}
} |
I have added the following code change into the library and it is working 1)Added new method in 'SlidingPanelLayout' class
P.S: Tested only for BOTTOM gravity case |
Maybe too late, but I achieve this using:
|
thx! |
No description provided.
The text was updated successfully, but these errors were encountered: