Android-ObservableScrollView Deployment and Usage Guide
Prerequisites
- Android Studio (latest stable version recommended)
- Android SDK with API level 9 or higher
- Gradle (included with Android Studio)
- Java Development Kit (JDK) 8 or higher
Installation
1. Add the Library Dependency
Add the following to your build.gradle file:
dependencies {
implementation 'com.github.ksoichiro:android-observablescrollview:VERSION'
}
Replace VERSION with the latest version available on Maven Central.
2. Clone and Install Manually (Optional)
If you want to install the library manually:
git clone https://github.com/ksoichiro/Android-ObservableScrollView.git
cd Android-ObservableScrollView
./gradlew installDevDebug
3. Download Sample App
Download the sample app from Google Play:
<a href="https://play.google.com/store/apps/details?id=com.github.ksoichiro.android.observablescrollview.samples2"><img alt="Get it on Google Play" src="https://play.google.com/intl/en_us/badges/images/generic/en-play-badge.png" height="50px"/></a>
Configuration
1. Layout Configuration
Replace standard scrollable views with ObservableScrollView equivalents:
<com.github.ksoichiro.android.observablescrollview.ObservableListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.github.ksoichiro.android.observablescrollview.ObservableScrollView
android:id="@+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView
android:id="@+id/recycler"
android:layout_width="match_parent"
android:layout_height="match_parent" />
2. Activity Configuration
Implement ObservableScrollViewCallbacks in your activity:
public class MyActivity extends AppCompatActivity implements ObservableScrollViewCallbacks {
private ObservableListView listView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
listView = findViewById(R.id.list);
listView.setScrollViewCallbacks(this);
}
@Override
public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
// Handle scroll events
}
@Override
public void onDownMotionEvent() {
// Handle down motion events
}
@Override
public void onUpOrCancelMotionEvent(ScrollState scrollState) {
// Handle up or cancel motion events
}
}
Build & Run
1. Building the Library
To build the library:
./gradlew build
2. Running the Sample App
To run the sample app:
./gradlew installDebug
Then launch the app from your Android device or emulator.
3. Running Tests
To run tests:
./gradlew test
Deployment
1. Publishing to Maven Central
To publish the library to Maven Central:
- Configure your
gradle.propertieswith Sonatype credentials - Run the following command:
./gradlew uploadArchives
2. Building for Production
For production builds:
./gradlew assembleRelease
Sign the APK using your keystore and upload to the Google Play Store.
Troubleshooting
1. Common Issues
Issue: java.lang.NoClassDefFoundError: com.github.ksoichiro.android.observablescrollview.ObservableListView
Solution: Ensure the library dependency is correctly added to your build.gradle file and that you've synced the project.
Issue: Scroll events not firing
Solution: Make sure you've implemented ObservableScrollViewCallbacks and set the callbacks using setScrollViewCallbacks().
Issue: Compatibility issues with RecyclerView
Solution: Use ObservableRecyclerView instead of the standard RecyclerView and ensure you're using the correct support library version.
2. Getting Help
- Check the FAQ for common questions
- Review the documentation for detailed usage
- Report issues on the GitHub repository
3. Contributing
If you'd like to contribute:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
Please follow the contributing guidelines.