片段覆盖另一个可以关闭的片段向上滑动
Fragment over another fragment that can be closed swiping up
我已经将片段 A 全屏覆盖在另一个片段 B 上。我想处理可以关闭片段 A 向上滑动并向下滑动重新打开它的滑动触摸。
我制作了这个示例图片:
我该如何实施?我还没有找到关于这个特殊案例的任何教程。谢谢。
compile 'me.imid.swipebacklayout.lib:library:1.0.0'
<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="com.example.darwich.swipetoclose.MainActivity">
<RadioGroup
android:id="@+id/id_radioGroup"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/mode_left"
android:text="Left"
android:textSize="24sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RadioButton
android:id="@+id/mode_right"
android:text="Right"
android:textSize="24sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RadioButton
android:id="@+id/mode_bottom"
android:text="Bottom"
android:textSize="24sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RadioButton
android:id="@+id/all"
android:text="All"
android:textSize="24sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RadioGroup>
</RelativeLayout>
public class MainActivity extends SwipeBackActivity {
private SwipeBackLayout swipeBackLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
RadioGroup trackingModeGroup = (RadioGroup) findViewById(R.id.id_radioGroup);
swipeBackLayout = getSwipeBackLayout();
trackingModeGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
int edgeFlag;
switch (checkedId) {
case R.id.mode_left:
edgeFlag = SwipeBackLayout.EDGE_LEFT;
break;
case R.id.mode_right:
edgeFlag = SwipeBackLayout.EDGE_RIGHT;
break;
case R.id.mode_bottom:
edgeFlag = SwipeBackLayout.EDGE_BOTTOM;
break;
default:
edgeFlag = SwipeBackLayout.EDGE_ALL;
}
swipeBackLayout.setEdgeTrackingEnabled(edgeFlag);
}
});
}
}
经过多次研究,我找到了一个库,可以非常轻松地实现滑动面板。
这是 Umano Android 面板
我已经将片段 A 全屏覆盖在另一个片段 B 上。我想处理可以关闭片段 A 向上滑动并向下滑动重新打开它的滑动触摸。
我制作了这个示例图片:
我该如何实施?我还没有找到关于这个特殊案例的任何教程。谢谢。
compile 'me.imid.swipebacklayout.lib:library:1.0.0'
<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="com.example.darwich.swipetoclose.MainActivity">
<RadioGroup
android:id="@+id/id_radioGroup"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/mode_left"
android:text="Left"
android:textSize="24sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RadioButton
android:id="@+id/mode_right"
android:text="Right"
android:textSize="24sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RadioButton
android:id="@+id/mode_bottom"
android:text="Bottom"
android:textSize="24sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RadioButton
android:id="@+id/all"
android:text="All"
android:textSize="24sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RadioGroup>
</RelativeLayout>
public class MainActivity extends SwipeBackActivity {
private SwipeBackLayout swipeBackLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
RadioGroup trackingModeGroup = (RadioGroup) findViewById(R.id.id_radioGroup);
swipeBackLayout = getSwipeBackLayout();
trackingModeGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
int edgeFlag;
switch (checkedId) {
case R.id.mode_left:
edgeFlag = SwipeBackLayout.EDGE_LEFT;
break;
case R.id.mode_right:
edgeFlag = SwipeBackLayout.EDGE_RIGHT;
break;
case R.id.mode_bottom:
edgeFlag = SwipeBackLayout.EDGE_BOTTOM;
break;
default:
edgeFlag = SwipeBackLayout.EDGE_ALL;
}
swipeBackLayout.setEdgeTrackingEnabled(edgeFlag);
}
});
}
}
经过多次研究,我找到了一个库,可以非常轻松地实现滑动面板。
这是 Umano Android 面板