{"id":13396030,"url":"https://github.com/r0adkll/Slidr","last_synced_at":"2025-03-13T22:31:35.778Z","repository":{"id":19831299,"uuid":"23092563","full_name":"r0adkll/Slidr","owner":"r0adkll","description":"Easily add slide to dismiss functionality to an Activity ","archived":true,"fork":false,"pushed_at":"2023-10-02T12:31:05.000Z","size":15572,"stargazers_count":2677,"open_issues_count":23,"forks_count":389,"subscribers_count":59,"default_branch":"master","last_synced_at":"2024-07-31T18:16:19.785Z","etag":null,"topics":["android","java","library","swipe-gestures"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/r0adkll.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2014-08-19T01:32:08.000Z","updated_at":"2024-07-25T12:30:43.000Z","dependencies_parsed_at":"2022-06-29T18:22:51.253Z","dependency_job_id":"2613e136-3607-420f-a337-db951ca9c4d5","html_url":"https://github.com/r0adkll/Slidr","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r0adkll%2FSlidr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r0adkll%2FSlidr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r0adkll%2FSlidr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r0adkll%2FSlidr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/r0adkll","download_url":"https://codeload.github.com/r0adkll/Slidr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243493735,"owners_count":20299711,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","java","library","swipe-gestures"],"created_at":"2024-07-30T18:00:38.008Z","updated_at":"2025-03-13T22:31:35.772Z","avatar_url":"https://github.com/r0adkll.png","language":"Java","funding_links":[],"categories":["Index `(light-weight pages)`","Index","Android","滑动返回","Uncategorized","Libs"],"sub_categories":["Uncategorized","\u003cA NAME=\"Animations\"\u003e\u003c/A\u003eAnimations"],"readme":"# Deprecated\nThis library is no longer supported as the modern convention of building Android apps switches from multi-Activity to single-Activity. If you are looking for similar behavior look into supporting Android's new [predictive back handling](https://developer.android.com/guide/navigation/custom-back/predictive-back-gesture)\n\nSlidr\n================\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.r0adkll/slidableactivity/badge.svg?style=flat)](https://maven-badges.herokuapp.com/maven-central/com.r0adkll/slidableactivity) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Slidr-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/1364)\n[![Build Status](https://travis-ci.org/r0adkll/Slidr.svg?branch=master)](https://travis-ci.org/r0adkll/Slidr)\n\nEasily add slide-to-dismiss functionality to your Activity by calling `Slidr.attach(this)` in your `onCreate(..)` method.\n\n![Slidr Example](images/slidr_gif.gif \"Gif Example\")\n\n## Usage\n\nAn example usage:\n\n```java\npublic class ExampleActivity extends \u003cActivity|FragmentActivity|ActionBarActivity\u003e {\n\n\t@Override\n\tpublic void onCreate(Bundle savedInstanceState){\n\t\tsuper.onCreate(savedInstanceState);\n\t\tsetContentView(R.layout.activity_example);\n\t\tint primary = getResources().getColor(R.color.primaryDark);\n\t\tint secondary = getResources().getColor(R.color.secondaryDark);\n\t\tSlidr.attach(this, primary, secondary);\n\t}\n\n}\n```\n\nor\n\n```java\npublic class ExampleActivity extends \u003cActivity|FragmentActivity|ActionBarActivity\u003e {\n\n\t@Override\n\tpublic void onCreate(Bundle savedInstanceState){\n\t\tsuper.onCreate(savedInstanceState);\n\t\tsetContentView(R.layout.activity_example);\n        \tSlidr.attach(this);\n\t}\n\n}\n```\n\n## Fragments\nThe activity must extend FragmentActivity.\nSet the background to the main container of the activity in the xml `background=\"@android:color/transparent\"`.\nAdd the following code to the Fragment:\n\n```java\n// This interface is needed to see if the fragment\n// is resuming after creation (Slidr to be attached) or\n// simply from the background (app was paused before).\nSlidrInterface slidrInterface;\n\n@Override\npublic void onResume() {\n    super.onResume();\n    if(slidrInterface == null)\n        slidrInterface = Slidr.replace(getView().findViewById(R.id.content_container), new SlidrConfig.Builder().position(SlidrPosition.LEFT).build());\n}\n```\nIn the xml of the fragment's view, the root view must be a FrameLayout with the same background set to the activity before. Add a child viewgroup to it with the id content_container. E.g.:\n\n```xml\n\u003cFrameLayout\n    android:id=\"@+id/main_container\"\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:background=\"@android:color/transparent\"\u003e\n    \n    \u003candroid.support.design.widget.CoordinatorLayout\n        android:id=\"@+id/content_container\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\u003e\n\t\n\t\t...other stuff\n\n    \u003c/android.support.design.widget.CoordinatorLayout\u003e\n\u003c/FrameLayout\u003e\n```\nRemember: you have to add new Fragments with:  \n\n```java \ngetSupportFragmentManager().beginTransaction()\n\t.add(R.id.fragment_container, YourFragmentClass.newInstance())\n\t.commit();\n```\n\nwhere fragment_container is the id of a FrameLayout inside the activity's xml.\n\n\n## Configuring\n\n```java\nSlidrConfig config = new SlidrConfig.Builder()\n\t.primaryColor(getResources().getColor(R.color.primary)\n\t.secondaryColor(getResources().getColor(R.color.secondary)\n\t.position(SlidrPosition.LEFT|RIGHT|TOP|BOTTOM|VERTICAL|HORIZONTAL)\n\t.sensitivity(1f)\n\t.scrimColor(Color.BLACK)\n\t.scrimStartAlpha(0.8f)\n\t.scrimEndAlpha(0f)\n\t.velocityThreshold(2400)\n\t.distanceThreshold(0.25f)\n\t.edge(true|false)\n\t.edgeSize(0.18f) // The % of the screen that counts as the edge, default 18%\n\t.listener(new SlidrListener(){...})\n\t.build();\n\nSlidr.attach(this, config);\n\n```\n\n---\n\n`Slidr.attach(...)` will return a `SlidrInterface` which gives you access to two methods:\n\n```java\nSlidrInterface.lock();\nSlidrInterface.unlock();\n```\n\nThese methods lock or unlock the slidable touch interface.\n\nThe theme that you use for your sliding activity must have these attributes set:\n\n```xml\n\u003citem name=\"android:windowIsTranslucent\"\u003etrue\u003c/item\u003e  \n\u003citem name=\"android:windowBackground\"\u003e@android:color/transparent\u003c/item\u003e\n```\n\nThen in the layout of your activity you must give it a background like this;\n\n```xml\n\u003cLinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n    android:orientation=\"vertical\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:background=\"@color/background_material_light\"\u003e\n\n    ...\n```\n\n## Including in your project\n\nInclude this line in your gradle build file:\n\n```groovy\nimplementation 'com.r0adkll:slidableactivity:2.1.0'\n```\n\n\u003c!--  \nFor Snapshots, include these lines in your gradle files:\n\n```groovy\nrepositories {\n    jcenter()\n    maven { url \"https://oss.sonatype.org/content/repositories/snapshots/\" }\n}\n```\n\n```groovy\ndependencies{\n\timplementation 'com.r0adkll:slidableactivity:2.0.7-SNAPSHOT'\n}\n```\n--\u003e\n\n\n## Author\n\n-\tDrew Heavner, **[r0adkll](http://r0adkll.com)**\n\n## License\n\n\tCopyright (c) 2014 Drew Heavner\n\n\tLicensed under the Apache License, Version 2.0 (the \"License\");\n\tyou may not use this file except in compliance with the License.\n\tYou may obtain a copy of the License at\n\n\thttp://www.apache.org/licenses/LICENSE-2.0\n\n\tUnless required by applicable law or agreed to in writing,\n\tsoftware distributed under the License is distributed on an\n\t\"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\n\teither express or implied. See the License for the specific\n\tlanguage governing permissions and limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr0adkll%2FSlidr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fr0adkll%2FSlidr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr0adkll%2FSlidr/lists"}