java - How to make a color gradient in a SeekBar? -


i want use seekbar (i.e. old school java slider) color gradient picker. have seen examples require making new classes , such. there has got way modify or override original classes. or replace background gradient.

i figured out here how it.

you create standard seekbar in xml.

<seekbar        android:id="@+id/seekbar_font"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:layout_margin="10px"        android:layout_below="@id/color_font_text"        android:max="100"        android:progress="50"></seekbar> 

then customize seekbar in oncreate() creating boxshape , force lineargradient inside it.

lineargradient test = new lineargradient(0.f, 0.f, 300.f, 0.0f,          new int[] { 0xff000000, 0xff0000ff, 0xff00ff00, 0xff00ffff,       0xffff0000, 0xffff00ff, 0xffffff00, 0xffffffff},        null, tilemode.clamp); shapedrawable shape = new shapedrawable(new rectshape()); shape.getpaint().setshader(test);  seekbar seekbarfont = (seekbar)findviewbyid(r.id.seekbar_font); seekbarfont.setprogressdrawable( (drawable)shape ); 

here image of current code above seekbar color gradient


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -