I'm using undetermined ProgressDialog with text 'Loading...' and other similar texts.
I decided to remove texts and leave plain progres indicator.
Unexpectedly sizde of indicator remain big enought to contain text inside.
How to remove it?
Update:
m_progressBar = new ProgressDialog(LoginForm.this);
m_progressBar.setIndeterminate(true);
m_progressBar.setCancelable(true);
m_progressBar.setProgressStyle(android.R.attr.progressBarStyleSmall);
Try editing your xml
<ProgressBar
style="?android:attr/progressBarStyleSmall"
You have to use custom ProgressBar google it there are a lot of example of creating custom ProgressBar. you cant do with android own ProgressBar
Unfortunately only custom progress solves this.
There are a lot of samples here in stackoverflow.com
Related
I want to show progress in a widget via a wheel-progressbar (not the horizontal one).
This is the progressbar in the xml layoutfile, that shows the content to the user:
<ProgressBar
android:id="#+id/progressBar1"
style="#android:style/Widget.ProgressBar.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminateOnly="false"/>
In the appwidget_provider implementation I wanted to set the progressbar like this:
RemoteViews views = new RemoteViews(context.getPackageName(),R.layout.sample_widget);
views.setProgressBar(R.id.progressBar1, 2, 1, false);
appWidgetManager.updateAppWidget(appWidgetId, views);
(sample_widget being the layout shown to the user)
Now, if progressBar1 is a horizontal progressBar, everything is displayed as you would expect.
But if I use any other style, like here, the progressbar is not displayed as soon as setProgressBar() sets indeterminate to false.
I presume that is because the wheel-progressbars are apparently designed to show only indeterminate behaviour, so the drawable for determinate behaviour does not exist, which
leads to the progressbar not being displayed.("If you will use the progress bar to show real progress, you must use the horizontal bar.", according to the documentation here)
My question is now how I would go about making a wheel-progressbar that is capable of
showing actual progress ? Furthermore I wanted to be able to customize the progressbar based
on user preferences or how much progress has currently been made ( maybe dynamically change the colour of the bar, make it brighter/darker, bolder/thinner, etc.).
I would really appreciate it if someone could point me in the right direction, because I assume I am pretty much overthinking it now.I believe there must be a simple way of doing it, I just did not find anything on the matter.
I was wondering if anyone can provide hint or source to achieve following slider widget used in "Circle – Who's Around?" This is the first time I have ever came across this and I am not sure what to exactly name this widget.:
I was thinking of using custom seekbar background to do this but, I am not sure how do I figure out exact pixels that the seekbar will reach of next step. Since, that will be independent to devices. In my case I am planning to use images, rather than the indicators.
Please don't point to this link http://www.mokasocial.com/2011/02/create-a-custom-styled-ui-slider-seekbar-in-android/ because this is not what I want to achieve. They seem to have used static image footer to show D,W,K. I have tried that app and it doesn't even step to the exact dots or D,W,K. I have looked at AT&T Android Slider Controls but, they don't seem to provide any source for it. I have found some iOS devs achieving that but, I don't really understand obj C code in order to achieve that in Android.
This is just a seekbar with a custom thumb and background. You could use a 9patch for the background so it fills nicely and just set them in your styles
Following #Milanix answer using the library at https://github.com/karabaralex/android-comboseekbar here it is a minimum example code that worked for me:
<com.infteh.comboseekbar.ComboSeekBar
android:id="#+id/seekbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
custom:color="#000"
custom:textSize="12sp"
custom:multiline="false"
/>
Then in the Activity
private ComboSeekBar mSeekBar;
List<String> seekBarStep = Arrays.asList("All","1","5","10","20");
mDistanceSeekBar.setAdapter(seekBarStep);
This will create a black segmented seekbar using default drawables. If you need to add some customization have a look at ComboSeekBar.onDraw(), CustomDrawable.draw() and CustomThumbDrawable.draw().
This project is all but finished but still a solid starting point.
#Giulio thank you for your post, I have the same problem as Ron Eskinder.
I heve fixed it by removing :"custom:color" , "custom:textsize" and "custom:multiline" in xml file. then in Java I put this:
mSeekBar = (ComboSeekBar) findViewById(R.id.seekbar);
List<String> seekBarStep = Arrays.asList("All","1","5","10","20");
mSeekBar.setAdapter(seekBarStep);
Hope this will help
I am designing something that will have a homepage close to the Google+ android app.
I'm having trouble figuring out the best way to do this? Should I create a button with text and set the background as the image? Should I create an image with the text already programmed in the actual picture or should I program the text and picture to be buttons.
Any suggestions from you guys on past projects?
You can use a Button with text to whatever you like and then place the image for that button above the text (using android:drawableTop)like so:
<Button
android:id="#+id/imageButton"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Photos"
android:drawableTop="#drawable/button_image" />
replacing buttton_image with your actual image. If you want the image in a different position (i.e. below text etc) use:
android:drawableLeft
android:drawableRight
android:drawableBottom
This would be how I would and do do it...
Since I am a newbie in android development I may be wrong but I suggest why not use a Grid View with each grid item haaving a textview and imageview.
My suggest to layout:
If you want to try something new in Android 4.0 , you can try GridLayout to layout , it can reduce the complicate of the nested layout , check out the blog about GridLayout:
http://android-developers.blogspot.com/2011/11/new-layout-widgets-space-and-gridlayout.html
You should write Buttons this way: http://developer.android.com/resources/articles/layout-tricks-merge.html
I normally use RelativeLayout but this is not important.
Write a class myClass extends RelativeLayout and inflate the XML with
LayoutInflater.from(context).inflate(R.layout.myCustomLayout, this, true);
I think this is best practice by Google.
use a regular button and set the android:drawableTop="#drawable/icon_...." value
Having the text burnt into you image is most certainly not the way to go.
One option for you is a GridView. You could also do this through a combination of Image button and scrollview. In my opinion, GridView is best and involves the least amount of code with most flexibility.
Remember that you can replace the button's background image with a state list drawable.
I am working on Android application.I am using Spinner control and added items to it.
Is there a way to change the background color of items in spinner.
can any one help me in sorting out this issue.
Thanks in Advance,
If you completely want to customize your background spinner, you should use 9patch background.
Here is a tutorial that explain how to do that :
http://www.gersic.com/blog.php?id=57
Otherwise, the solution given by user432209 is the simplest.
However, if you want to do that in xml layout :
<Spinner android:id="#+id/spinner"
...
android:background="#YOUR_HEXA_COLOR"/>
You can use
yourView.setBackgroundColor(int color)
You can also use android:popupBackground="YOUR COLOR" which will define the items background not the whole spinner's background.
I would like to create an android widget with a scrollable textview.
The solutions given to this question
Making TextView scrollable on Android
cannot be applied because it is a widget:
1.
This
findViewById(R.id.textview).setMovementMethod(new MovementMethod());
does not work, since findViewById is not available in AppWidgetProvider but only in Activity.
2.Putting a ScrollView around the TextView also does not work, because I get an
InflateException:
android.view.InflateException: Binary XML file line #23: Error inflating class ScrollView
Can anybody give me a hint, how to make a TextView in a Widget scrollable?
I solved this problem by putting the text view inside ListView with single node, which is supported in App widget.
http://developer.android.com/guide/topics/appwidgets/index.html#collections
It looks like this is not possible.
More on this can be found here: http://code.google.com/p/android/issues/detail?id=9580
and here:
How to make a scrollable app widget?
So, probably it is possible to do make appwidgets scrollable in the HTC sense environment but not for normal android environments.
A way around this is to add buttons that go up and down in a list.
I have been working on this with two buttons which increment and decrement through an array. Just having trouble accessing the global variables. Did you make any headway on this?
Another solution is:
Add to textview any web link - for example: www.google.com.
Setting text value with HtmlCompat.fromHtml method:
textView.setText(HtmlCompat.fromHtml("some text" + "\nwww.google.com", HtmlCompat.FROM_HTML_MODE_COMPACT));
After that vertical scrollbar is appeared.
But it's not elegant and full solution. It's temporary workaround maybe...
The complete full solutiion is bat-el-g 's answer - with adding ListView.
Current marked solution (which just tell: "it's not possible") - is wrong.
In mainactivity.java:
after code text view:
TextView txt = (TextView) findViewById(R.id.textView id);
Enter this code:
txt.setMovementMethod(new ScrollingMovementMethod());
and you will be ok.