Skip to content

Android Stories library - Instagram-like android stories library that supports images from disk or from internet (url)

Notifications You must be signed in to change notification settings

MrMak21/Android-Stories

Repository files navigation

Android Stories Library

Instagram like stories library for Android.

Alt text Alt text Alt text

Add it in your root build.gradle at the end of repositories:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Step 2. Add the dependency

dependencies {
	        implementation 'com.github.MrMak21:Android-Stories:1.1.4'
	}

Usage

  • Add view to Activity/Fragment layout
<gr.makris.androidstories.Stories
        android:id="@+id/stories"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:progressBarBackgroundColor="@color/gray" // --> progressBar bacground color
        app:progressBarColor="@color/white" // --> progressBar color
        app:storyDuration="3" // --> in seconds
        app:loadingViewProgressColor="@color/purple_700" />
  • You can also change the progress bar color & the background with these attributes
 app:progressBarBackgroundColor="@color/gray"
        app:progressBarColor="@color/white"
  • Then create a StoryItem() lists and pass it to Stories view.
    Kotlin example:
val storiesList = listOf<StoryItem>(
           StoryItem(url = "https://picsum.photos/300/500"),
           StoryItem(src = "R.drawable.cool_image"),
           StoryItem(url = "https://picsum.photos/300/500"),
           StoryItem(src = "R.drawable.cool_image_2")
       )

       val storiesView = findViewById<Stories>(R.id.stories)
       storiesView.setStoriesList(storiesList)
  • The StoryItem object can take 2 types of parameters:
  1. String (Useful for url's containing images)
  2. Int (You can load a Drawable file)

  • Also Android Stories library view containing all the instagram-like functionality. Press to the right to go next story, press to the left to go to the previous story or hold to pause time.

  • Android Stories library view also contains a callback so you know when the stories come to an end.
    All you have to do is implement StoriesCallback in your Activity/Fragment and override onStoriesEnd() method.
    Kotlin example:
class MainActivity : AppCompatActivity(), StoriesCallback
	...
   ...
   override fun onStoriesEnd() {
       	//do something
   }

Upcoming things

  • Set marginStart & marginEnd of story-progress view from xml
  • Set margin between every story-progress line on top of the view
  • Support videos

About

Android Stories library - Instagram-like android stories library that supports images from disk or from internet (url)

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published