在我的应用程序中,我有slidingPaneLayout
<com.abc.qwe.widget.SlidingPaneLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/sp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/drawer_view"
android:layout_width="@dimen/drawer_size"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_gravity="start"
android:background="@color/main_blue_color">
<ListView
android:id="@+id/left_drawer"
android:layout_width="match_parent"
android:layout_height="0dp"
android:choiceMode="singleChoice"
android:scrollbars="none"
android:divider="@color/menu_list_divider_color"
android:dividerHeight="1dp"
android:layout_weight="1"
android:footerDividersEnabled="false"
android:cacheColorHint="@android:color/transparent"
android:listSelector="@drawable/selector_list"
android:headerDividersEnabled="true"/>
</LinearLayout>
<RelativeLayout
android:id="@+id/aaa
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
</RelativeLayout>
</com.abc.qwe.widget.SlidingPaneLayout>
当打开slidingPaneLayout时,我想禁用所有点击,在FrameLayout中滑动任何操作。
当关闭slidingPaneLayout时,我想启用所有点击,在FrameLayout中滑动任何操作。
我怎么能这样做?
RelativeLayout layout = (RelativeLayout) findViewById(R.id.aaa);
for (int i = 0; i < layout.getChildCount(); i++) {
View child = layout.getChildAt(i);
child.setEnabled(false);
}
我这样做但是没有用。
答案 0 :(得分:1)
在onClickListener
中,检查是否打开了slidingPanelLayout,
if (opened){
return ;
}
当slidingPanelLayout的偏移量为0或等于屏幕宽度时,您可以假设它是打开/关闭的。
答案 1 :(得分:0)
public static View _View;
public static SlidingPaneLayout _Pane;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
_View = inflater.inflate(R.layout.activity_contacts_list, container, false);
_Pane = (SlidingPaneLayout) _View.findViewById(R.id.sp);
_Pane.setPanelSlideListener(new PaneListener());
return _View;
}
private class PaneListener implements SlidingPaneLayout.PanelSlideListener {
@Override
public void onPanelClosed(View view) {
System.out.println("Panel closed");
}
@Override
public void onPanelOpened(View view) {
System.out.println("Panel opened");
}
@Override
public void onPanelSlide(View panel, float slideOffSet) {
System.out.println("Panel sliding");
}
}