View color specific to touch point - android

I wanna make a bar which changes to a different colour until the point where it is touched. Like this:

A seek bar will probably suit your needs very well, since you can customize the bar color, the bar itself and the progress indicator.
If you want it vertical you can probably use setRotation() (even though I'm not sure since I never actually used it I don't see why it wouldn't work).

Related

Android Seekbar with progress bar on thumb

I am trying to create a seekbar with horizontal progress bar on thumb. Visually it should look something like this.
So when i seek the thumb left to right the progress bar will act according to the value of seekbar.
So far i had try to overlap a progress bar on the top of seekbar, but this is not working as expected. Also i am not able to pass the touch event from progress bar to seekbar. As progress bar is overlapping the thumb i need to bypass the touch event from progress bar to seekbar thumb, which i am not able to achieve it.
Can anyone help me changing existing code or completely create a new custom seekbar by extending base class.
If you don't want to code the wohle thing yourself, there is a github project that displays the value inside the thumb. However, this is not very similar to the image you provided, but maybe could be styled.
The other option is coding it yourself. You will basically have to extend SeekBar and override the most important methods ( onDraw, onMeasure etc. )
There are plenty of tutorials on how to make custom views, like this one from the android developer pages.

Custom steps progress bar in android

I want to create a custom progress bar that looks like this
http://i.stack.imgur.com/NK5Px.png
it should progress until it reaches one of the circles light it up and continue towards the next one until it reaches the last one.
What is the best approach to implement this?
- whether to extend progress bar and override onMeasure() & onDraw()
- or to create compound component with layout as root and populate it with progress bar
and some circle like views.
Update
on the first approach i wonder how to make the progress bar half the size of the control and center it?
the other approach will make me use nested layouts, and seems to be more complex to create..What do you think? there is a completely different way to do it properly and easily?

How to implement a dynamic background on ActionBar like 7x7?

If you have ever played 7x7 you've surely noticed the ActionBar changing his background progressively with your points until a new level is reached.
I really like the effect and I was thinking to use it somewhere. Do you have any clue on how implement it?
I'm not sure if it could be achieved drawing a Rect over it, any help?
Thanks in advance
This is my game! I actually made a custom Action Bar that was transparent and added the level progress bar underneath it.
If you wanted to use the default Action Bar, you could probably do the same with windowActionBarOverlay.

How can I make Seekbar non touchable?

I have scenario where I have to show some level using a progress bar, but according to the design this progress bar has a thumb like circle on it too.
Now the user is not supposed to change the value of this bar either by touch or by using keys.
The 'thumb' is available in Seek bar but not in Progress bar, but Seek bar is capable of taking focus and touch events, while this should not happen in my case.
So for handling the focus and make my seek bar "foussable = false" & "focussableInTouchMode = false", but what should I do to make it non-touchable almost like a progress bar ?
Another option is to call setOnTouchListener and use a listener that always returns false. Note that this UI is confusing to users as you want the seekbar to look like an active one, but not behave like an active seekbar. For UI consistency, using setEnabled(false) is more consistent, and the colors are different for a good reason.
what you can do is, create custom seekbarwith following two property, and call enable(false)
android:progressDrawable="#drawable/progress_bar"
android:thumb="#android:color/transparent" // to make thumb invisible
and then call for runtime
SeekBar.setEnabled(false)
and from xml
android:enabled="false"

Action Bar Checkable Icons?

I was wondering if it were at all possible to have checkable icons in an action bar in ICS? Not with a check, but with a android:stateChecked property to play around with. I want it so when the user clicks on the icon, they enter a certain mode (and the background of the icon would be a bright color to let them know they are still in that mode), and when they click it again they are taken out of that mode. I've played around with some selector xmls but nothing has worked...Any ideas?
EDIT: I just learned that Checkable items cannot appear in main menus, they can only be in submenus. However, is there a way to still get the behavior of a checkable? It's easy enough to have a boolean like isInModeA, but is there a way to programmatically change the background/icon of an Action bar item?
There is a way to programmatically change the background/icon.
You can use ActionBar.setBackgroundDrawable, for instance, or setCustomView, or setIcon (found on the same page).
You may consider using a dropdown-like ActionProvider to provide e.g. a radio-button-like "on/off" rather than a checkbox.
One approach you could try is to keep the state saved in some variable and just display different items based on this state. Obviously, some of these items can change the state. You might look at doing this by implementing a custom action provider.

Categories

Resources