Skip to main content

Custom Android SeekBar Developement

Before starting coding for Custom SeekBar,You must have good concept of following topics.
 
Layer List:A LayerDrawable is a drawable object that manages an array of other drawables. Each drawable in the list is drawn in the order of the list—the last drawable in the list is drawn on top.

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@android:id/background"
android:drawable="@drawable/seekbar_total"/>
<item android:id="@android:id/secondaryProgress">
<clip android:drawable="@drawable/seekbar_buffer" />
</item>
<item android:id="@android:id/progress">
<clip android:drawable="@drawable/seekbar_played" />
</item>
</layer-list>
Animation List:A AnimationDrawable is a drawable object that is used to create frame-by-frame animation.It's oneshot element should be true if u want loop animation otherwise false.

<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false" >
<item
android:drawable="@drawable/progressbar_indeterminate1"
android:duration="200"/>
<item
android:drawable="@drawable/progressbar_indeterminate2"
android:duration="200"/>
<item
android:drawable="@drawable/progressbar_indeterminate3"
android:duration="200"/>
</animation-list>
Selector:A controller for the selection of SelectableChannel objects.It has different properties like focus,pressed which is used to describe the current status of View.

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/seekthumb_hover" android:state_enabled="true" android:state_focused="true" android:state_pressed="false"/>
<item android:drawable="@drawable/seekthumb_onpress" android:state_enabled="true" android:state_pressed="true"/>
<item android:drawable="@drawable/seekthumb_active" android:state_enabled="true" android:state_focused="false" android:state_pressed="false"/>
<item android:drawable="@drawable/seekthumb_normal" android:state_enabled="false" android:state_focused="true"/>
<item android:drawable="@drawable/seekthumb_normal" android:state_enabled="false" android:state_focused="false"/>
<item android:drawable="@drawable/seekthumb_active"/>
</selector>

Now you need following images for desinging SeekBar 


1.seekbar_total.9.png 
2.seekbar_buffer.9.png 
3.seekbar_played.9.png 
4.progressbar_indeterminate1.9.png 
5.progressbar_indeterminate2.9.png 
6.progressbar_indeterminate3.9.png 
7.seekthumb_hover.9.png 
8.seekthumb_onpress.9.png 
9.seekthumb_active.9.png 
10.seekthumb_normal.9.png

Now create xml layout
seekbar.xml
<SeekBar
android:id="@+id/mediacontroller_progress"
style="@style/SeekBarHorizontal"
android:layout_width="0dip"
android:layout_height="62dip"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true" />
Create styles.xml inside values folder.

<style name="SeekBarHorizontal">
<item name="android:indeterminateOnly">false</item>
<item name="android:progressDrawable">@drawable/progress_horizontal</item>
<item name="android:indeterminateDrawable">@drawable/progress_indeterminate_horizontal</item>
<item name="android:minHeight">62dip</item>
<item name="android:maxHeight">62dip</item>
<item name="android:thumb">@drawable/thumb_background</item>
<item name="android:scaleType">fitCenter</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
</style>





Comments

Popular posts from this blog

Android O New Features Overview

This post assumes, you are an experienced developer who wants to get started with the latest version of Android. Android O is not a huge update to the OS and application framework like M but it still has many useful features for both developer and an user. Android O has focus on below areas. Notification redesigned Picture-in-Picture(PIP)  Visual adaption for different devices  Battery life improved Setting app reorganized Notification redesigned: Android O notification changes includes more easy and manageable way to manager your notification behavior and settings. It includes: Notification Channel: Notification channel allows you to create user customizable channel for each type of notification you wanna display. A single application can have multiple channel, a separate channel for each type of notification you wanna display. Having said this, you can create s separate channel for audio & image notification. User can disable specific notification channel instead

Java 8 Overview

Java 1.8 has introduced major features for the Java developers. It includes various upgrade to the Java programming, JVM, Tools and libraries. The main purpose of Java 1.8 release has been to simplify programming, utilize functional programming benefits and enable parallel programming/processing in Java programming language. Java 1.8 feature  Lambda(->) Expression Functional interfaces Default Methods in interface static method inside interface     Pre defined functional interfaces Predicate Function Consumer ::(Method reference and constructor reference by using double colon(::)operator) Stream API Date & Time API

Overview of how to develop native code with Android NDK:

  Create a jni directory and place native source code under $PROJECT/jni/... Create Android.mk directory and place it under $PROJECT/jni/... to describe source code to the NDK build system. Create Application.mk and place it under $PROJECT/jni/...to describe project in more details to the NDK build system.It is an optional. Finally need to build native source code by running '$NDK/ndk-build' from project directory or it's sub-directory. Android.mk An Android.mk file is a small build script that we write to describe sources to the NDK build system. It's syntax is like this... LOCAL_PATH:=$(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE:=hello-jni LOCAL_SRC_FILES:=hello-jni.c include $(BUILD_SHARED_LIBRARY) NDK groups your sources into "modules", where each module can be one of the following: Static library Shared library We can write several module in a single 'Android.mk' or can write seve