For example, if you create multipain layout with SlidingPaneLayout
like this
<android.support.v4.widget.SlidingPaneLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android: id="@+id/sliding_plane_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android: id="@+id/left"
android:layout_width="240dp"
android:layout_height="match_parent"/>
<FrameLayout
android: id="@+id/right"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</android.support.v4.widget.SlidingPaneLayout>
If you look at this on your smartphone, when you open the left pane (@id/left
, the right pane (@id/right
) will not be able to operate (scroll or touch) (like when you open Navigation Drawer).
But when I see it on a tablet, I can use the right pane.
Rin wants to make it inoperable even when using a tablet
In other words, you want to look like Navigation Drawer
Therefore, I would like you to tell me how to make it inoperable other than changing the layout_width
in the left pane.
See Exploring SlidingPaneLayout and
I made the following arrangements myself, so please refer to them.
layout.xml
<android.support.v4.widget.SlidingPaneRayout xmlns:android="http://schemas.android.com/apk/res/android"
android: id="@+id/SlidingPanel"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android: id="@+id/covered"
android:layout_width="250dp"
android:layout_height="match_parent"
android:background="#CC00FF00"
android:text="Pane1"/>
<FrameLayout
android: id="@+id/right"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:color/darker_gray">
<!--Pre-configure the background with the color you want to fade-->
<TextView
android: id="@+id/hidden"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#CC0000FF"
android:text="Pane2"/>
</FrameLayout>
</android.support.v4.widget.SlidingPaneLayout>
Partial Activity.java
SlidingPaneLayout.PanelSlideListener panelListener=newSlidingPaneLayout.PanelSlideListener(){
@ Override
public void onPanelClosed(View arg0){
}
@ Override
public void onPanelOpened(View arg0){
}
@ Override
public void onPanelSlide(View arg0,float arg1){
//arg1 seems to contain 0 to 1
// https://developer.android.com/reference/android/support/v4/widget/SlidingPaneLayout.PanelSlideListener.html#onPanelSlide(android.view.View, float)
FrameLayout frameLayout=(FrameLayout)arg0;
View childView = frameLayout.getChildAt(0);
dimCustomChildView (childView, arg1);
}
private void dimCustomChildView (View v, float mag) {
// The method name is based on SlidingPaneLayout source code.
// // https://github.com/android/platform_frameworks_support/blob/master/v4/java/android/support/v4/widget/SlidingPaneLayout.java#L967
// The above method uses alpha value, bit operation, etc. to determine the condition of fade, and as a result of this, landscape.
// I don't know if the fade is stopped.I took out setAlpha.
// Someone please explain!!
if(mag>0&&mag<=1){
v.setAlpha(1-mag);
}
}
};
Thank you for your cooperation.
© 2024 OneMinuteCode. All rights reserved.