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"
Related
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).
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.
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?
Is it possible to have three states in a progress bar?
I know how to set a secondary state, but there is no tertiary state. How do I expand a progress bar to handle that?
greetings, tata
Looking at the source code for the default system progress bar at ProgressBar.java shows that there is hardcoded limit of two bars at once...
The easiest way for you may probably be copying the progressbar source to your project and add another bar by yourself.
Since there is a secondary progress bar already present, additional ones should not pose any extra difficult challenge (just follow the example of the secondary one).
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.