[embedyt] https://www.youtube.com/watch?v=Ci5146VOyg4[/embedyt]
Links & Dependenciesactivity_2.xmlActivity2.javaactivity_main.xmlMainActivity.javastyles.xmlAndroidManifest.xml
Library on GitHub with dependency + instructions:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/background_material_light" android:gravity="center" android:orientation="vertical" tools:context="com.codinginflow.slidrexample.Activity2"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="This is Activity 2" android:textSize="30sp" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:onClick="lockSlide" android:text="Lock slide" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:onClick="unlockSlide" android:text="Unlock slide" /> </LinearLayout>
package com.codinginflow.slidrexample; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import com.r0adkll.slidr.Slidr; import com.r0adkll.slidr.model.SlidrInterface; public class Activity2 extends AppCompatActivity { private SlidrInterface slidr; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_2); slidr = Slidr.attach(this); } public void lockSlide(View v) { slidr.lock(); } public void unlockSlide(View v) { slidr.unlock(); } }
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" tools:context="com.codinginflow.slidrexample.MainActivity"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:onClick="openActivity2" android:text="Open Activity 2" /> </LinearLayout>
package com.codinginflow.slidrexample; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public void openActivity2(View v) { Intent intent = new Intent(this, Activity2.class); startActivity(intent); } }
<resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> </style> <style name="AppTheme.SlidrActivityTheme"> <item name="android:windowIsTranslucent">true</item> <item name="android:windowBackground">@android:color/transparent</item> </style> </resources>
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.codinginflow.slidrexample"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".Activity2" android:theme="@style/AppTheme.SlidrActivityTheme"></activity> </application> </manifest>