Thanks to Coding in flow for that. Watch this tutorial for more explanation.
Follow these steps to do the job.
1- We will use a library to do that called Slidr, use the last version.
// swipe the Activity to close
implementation 'com.r0adkll:slidableactivity:2.1.0'
2- Add a new style in your styles.xml called SliderActivityTheme.
This theme will make the background for the activity when swipe it as transparent to show the content of the fragment...etc, "default background white"
<!--Theme for Slider Activity-->
<style name="AppTheme.SliderActivityTheme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
</style>
3- A- Add slide method to your class and called in OnCreate
// Make slider on the Activity
public void Slider () {
Slidr.attach(this);
}
B- Called in OnCreate
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.your_activity_name_here);
// slider the activity
Slider();
}
or just simply add this in your OnCreate directly
// slider the activity
Slidr.attach(this);
4- In your AndroidManifest.xml add the theme that we had to create.
android:theme="@style/AppTheme.SliderActivityTheme"
Make it like that
<activity
android:name=".Activity.ActivityImages.ImagesMorningActivity"
android:launchMode="singleTop"
android:theme="@style/AppTheme.SliderActivityTheme"/>
<activity
That's all, and enjoy with your new feature ;)
Working with Fragment? No problem, check the library page to know how to do that