Friday, 15 January 2010

android - Inverting color of textview on SlidingTabStrip -



android - Inverting color of textview on SlidingTabStrip -

i need create animation due briefly invert color of textview while animation. i'm using slidingtablayout viewpager, this:

the colors reference.

the finish code here:

slidingtablayout: here slidingtabstrip: here

[update]

i've tried it:

int normaltextcolor = color.argb( 0, 0, 0, 0); int pressedfiltercolor = color.argb(225, 238, 11, 83); bitmap bitmap = bitmap.createbitmap(1, 1, bitmap.config.argb_8888); //make 1-pixel bitmap canvas canvas = new canvas(bitmap); canvas.drawcolor(normaltextcolor); //color want apply filter canvas.drawcolor(pressedfiltercolor, porterduff.mode.lighten); //apply filter int pressedtextcolor = bitmap.getpixel(0, 0); textview.settextcolor(pressedtextcolor);

but still not working.

as raybaybay said no simple way in android. going have work layers. if familiar photoshop or gimp, how layers are, if not take here http://docs.gimp.org/en/gimp-image-combining.html#gimp-concepts-layers. key here know how combine layers. start testing screen , multiply modes http://developer.android.com/reference/android/graphics/porterduff.mode.html. javadoc on porterduff modes useless, article (jump straight "transfer" section) should help http://www.xenomachina.com/2011/05/androids-2d-canvas-rendering-pipeline.html understand going on.

now, code see familiar android samples. should check graphics/xfermodes demo, on "apidemos" sample. can install straight eclipse: new > other > android sample project. demo shows porterduff modes there , how utilize them. hope helps.

android android-animation android-tabhost

No comments:

Post a Comment