Non-touchable seek bar but showing progress - android

I'm making a simple app for timing. It has a seek bar to set the time and a button to start or stop. It plays a short sound effect when the time's up. Almost everything is done but this, when the timer counts down, I would like the seek bar to keep track of the time, meaning the little dot on it moving backward as the timer counts. Of course the issue can be solved by using the listener but I want to make the seek bar non-touchable when the timer is counting but it still shows progress. Thank you for reading this, hope you have an answer for me.

You can use a ProgressBar and set it to:
progressBar.setIndeterminate(false);
Than you can update the progress by calling:
progressBar.setProgress(progress);
This is the regular style:
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/progressBar"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:max="100"
/>
If you want more sophisticated types of progressbar take a look here: https://android-arsenal.com/tag/76

Related

How to create speed animation bar in Android?

I will be glad to get some help with how to do a speed animation bar for android app. Something like what is shown here so it fills up automatically but for an app.
So far I found this code, which pretty resembles what I was aiming for but
I don't want the animation to show on a pop up, but as part of the page.
If you are not sure please point me to the right source so I will figure out how this works.
Any help would be much appreciated:)
Add progress base in your activity layout (R.layout.main);
<ProgressBar
android:id="#+id/mybar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="38dp" />
And instead of doing this
progressBar = new ProgressDialog(v.getContext());
do this after setContentView();
progressBar = (ProgressBar) findViewById(R.id.mybar);

Custom seek bar with thumb and progressDrawable

I try to customize seek bar like below
But problem is that
-thumb image not set with text
-thumb position can not set above seekbar.
-android:progressDrawable should not repeat as below
My Code is as below:
<SeekBar
android:id="#+id/volume_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:max="100"
android:progress="20"
android:progressDrawable="#drawable/bar"
android:secondaryProgress="0"
android:thumb="#drawable/greenarrow" />
I've tried doing this, but I ran into problems with response time the way I did it. Having to move the margins took a lot of processing power and time. It was close to 400-500ms. So I had to remove it.
However, here are the steps I took:
First, I would suggest creating a frame layout to hold both the SeekBar and a TextView. Then, depending on the percentage of the progress bar, you can set the TextViews layout property margins.
Does that make sense?
If you would like specific code, I can get that to you, but google does pretty good too. :)
Option B: Android seekbar with custom thumb having dynamic text inside it

Custom auto complete with progress bar

I am trying to create a custom auto complete text view that contains a progress bar (circle in my case).My problem is that every time the user inputs a char a web service is accessed and there is some delay until a display some results.I would like to place a progress circle that will suggest to the user that there is some work in progress.As an excelent example of what i would want you could take a look at googles maps address auto complete.
Thanks for any suggestions.
I think an AutoCompleteTextView is something what you are looking for.
Also, link to a tutorial.
Edit: For the progress bar part, I would have had a infinite progress bar on the title bar of my application. I feel that would be a more complete solution as I can re-use it for any other task also. Something similar is discussed here.
Use the below code for the implementation
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<AutoCompleteTextView
android:id="#+id/lkjk"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:completionThreshold="3"
android:dropDownHeight="200dp"
android:ems="10"
>
<requestFocus />
</AutoCompleteTextView>
<ProgressBar
android:id="#+id/progress_bar"
android:layout_width="25dip"
android:layout_height="25dip"
android:layout_gravity="right" />
</FrameLayout>
Follow http://developer.android.com/resources/tutorials/views/hello-autocomplete.html think and user Progress bar and u need to Use Handler in this case

How to show a Horizontal Android Indeterminate Progress Bar

How to show an indeterminate horizontal progress bar in android? The animation of the progress bar should start from 0 to 100 and then go back from 100 to 0 continuously. I am not looking for the wheel progress bar.
I already knew that setIndeterminate will give an infinite horizontal progress bar. But it will be similar to the loading wheel, except that it will be horizontal. If you see my question I was looking for horizontal bar which starts from 0 and goes all the way to 100 (a gradual increase). If you want to achieve this in Android, you must use your progress bar as below:
<ProgressBar
android:id="#+id/progress_horizontal"
android:indeterminateOnly="false"
android:indeterminateDrawable="#drawable/progress_indeterminate_horizontal"
android:progressDrawable="#drawable/progress_horizontal"
android:minHeight="24dip"
android:maxHeight="24dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
As I wanted to change the background of my progress bar, I changed the ProgressDrawable and IndeterminateDrawable. The original drawables are located under frameworks/base/core/res/res/drawable. Copy them to your project and change the color according to your needs.
Create a thread which updates the progress count and does a Thread.Sleep. Then it sends the message to the Handler which will update the progress bar in UI thread.
Use the method setIndeterminate of ProgressBar:
android.widget.ProgressBar bar = new android.widget.ProgressBar(context);
bar.setIndeterminate(true);
But yeah, you could have found this pretty quickly in the developer docs.
http://developer.android.com/reference/android/widget/ProgressBar.html#setIndeterminate%28boolean%29
Maybe a bit late, but you can do something like this:
<ProgressBar
android:id="#+id/progress"
android:layout_width="match_parent"
android:layout_height="10dp"
android:indeterminate="true"
style="?android:attr/progressBarStyleHorizontal" />
Hope it helps someone!
To expand on Vinoth Answer, here is a ready code:
<ProgressBar
android:id="#+id/progressBarLoadingRecite"
android:indeterminateDrawable="#android:drawable/progress_indeterminate_horizontal"
android:minHeight="24dip"
android:layout_marginTop="20dip"
android:indeterminate="true"
android:maxHeight="24dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
In the xml defining your progress bar, you can add
style="#android:style/Widget.ProgressBar.Horizontal"

Set background drawable (Programmatically s)?

In my application I have something like this:
Button playBtn = (Button) findViewById(R.id.play);
ProgressBar pb1 = new ProgressBar(this);
playBtn.setBackgroundDrawable(pb1);
But this is not working. And I know why, - pb1 is not a drawable. But how otherwise I can set the background of my play button to the progress bar? I use a programmatic way of creating a progress bar and I have a play button in my .xml resource.
Ah, you really can't do what you're trying to do: there is no way to use one View as the background of another View.
What you can do is something similar to what the Android battery meter in the notification area does: make a number of drawables (I think the battery meter uses 5 or 6 different images, 1 for each stage of the recharge process) and then use a timer or external events to switch the background drawable for your button: this simulates a progress meter.
Let me know if that helps.
Make transparent button (background="#null") and place it on the ProgressBar using RelativeLayout or FrameLayout.
This is simpler than it seems:
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#null"
android:textColor="#android:color/white"
android:text="asdasd"/>
</FrameLayout>
Make the same in code if you want.
Are you sure you need the Button here? Mb it's enough to place the ProgressBar only and make it clickable by setting onClickListener.

Categories

Resources