Android Custom Horizontal ScrollView Example
https://www.viralandroid.com/2015/09/android-custom-horizontal-scrollview-example.html
In this example, I’m going to share a simple tip to make custom horizontal android ScrollView. Android has provided us lots of ScrollView attributes and with the help of these attributes, we can customize HorizontalScrollView in our own way.
Related:
Android Custom Vertical ScrollView Example
Android webview Tutorial with Example
Android Navigation Drawer View: Material Design Support Library
Let’s start by creating a new android project to customize android horizontal ScrollView with following information.
Application Name: Custom Horizontal ScrollView
Company Domain: viralandroid.com
Package Name: com.viralandroid.customhorizontalscrollview
Minimum SDK: Android 2.2 (API 8 Froyo)
Look at the following code I have added scrollbarThumbHorizontal and scrollbarTrackHorizontal xml attribute to customize android HorizontalScrollView. Following is the final code of xml layout file.
res/layout/activity_main.xml
Create two xml files horizontal_scrollview_track.xml and horizontal_scrollview_thumb.xml inside res/drawer and add following code.
res/drawer/horizontal_scrollview_track.xml
res/drawer/horizontal_scrollview_thumb.xml
Your default java activity file looks like this.
src/MainActivity.java
Now, run your application. Your application looks like above screenshot.
Related:
Android Custom Vertical ScrollView Example
Android webview Tutorial with Example
Android Navigation Drawer View: Material Design Support Library
Create a new Android Project
Let’s start by creating a new android project to customize android horizontal ScrollView with following information.
Application Name: Custom Horizontal ScrollView
Company Domain: viralandroid.com
Package Name: com.viralandroid.customhorizontalscrollview
Minimum SDK: Android 2.2 (API 8 Froyo)
Add ScrollView in XML Layout File
Look at the following code I have added scrollbarThumbHorizontal and scrollbarTrackHorizontal xml attribute to customize android HorizontalScrollView. Following is the final code of xml layout file.
res/layout/activity_main.xml
XML Drawable Resource
Create two xml files horizontal_scrollview_track.xml and horizontal_scrollview_thumb.xml inside res/drawer and add following code.
res/drawer/horizontal_scrollview_track.xml
res/drawer/horizontal_scrollview_thumb.xml
Java Activity File
Your default java activity file looks like this.
src/MainActivity.java
Now, run your application. Your application looks like above screenshot.