I don't seem to find a way to change the speed of the ProgressBar.
On devices with Kitkat and earlier the older ProgressBar is changing it's speed according to the indeterminateDuration attribut and it works. But on Lollipop, the new material ProgressBar is not being affected.
Do you know how it could be done?
Thanks!
You can use my library ProgressBarLP for your purpose. You can change the duration of the animation through which you can increase or decrease its speed. The attribute to change would be progressCycleDuration. The support is only from API 11 though.
Related
The number pickers in Android contain a shadow above the previous and next value(s). Is there a attribute to make this shadow transparent?
If an image is being used as the background, these shadows are distracting.
Edit:
Running emulator with Android version 6.0.
Setting the solidColor attribute makes the shadows appear in different colors. Unfortunately, setting it to transparent still keeps the black fading appearance.
How this renders during emulation with the background image:
I think it's just the Android version is too old. I didn't do any customization to numberpicker and it still looks flat (no ugly shadow like that). My test device running 6.0
I'm working with an EditText, and know that setTextAlignment was not implemented until API 17, but don't see how using setTextAlignment is any easier or better than setGravity. Which should I use for what purposes, or does it not matter?
I find setGravity to be very easy to work with and do what I want, so when should I NOT use this?
Thank you
setTextAlignment() is easier to work with in right-to-left locales: You can align by locale-specific text start or text end without needing to know if it's to the left or to the right.
textAlignment alone won't work. For many alignment modes, you need to actually combine it with a gravity.
setTextAlignment available from API Level 17, You can't use it before 17. But setGravity available from API Level 1. You can use it anywhere.
SetGravity
Sets the horizontal alignment of the text and the vertical gravity that will be used when there is extra space in the TextView beyond what is required for the text itself
I have been developing an app over the past few months getting ready for publication. Everything was looking just perfect. I was doing a few things with text in buttons - using my own 9-patch button backgrounds, changing the default font, repositioning textbuttons with setX() and setY() etc. I had some big buttons and smaller ones. Some were a tight fit amongst other objects on the screen, but it all worked, the buttons looked perfect on a variety of tablets and phones.
Then I remembered one last thing on my todo list which wast to change the android:minSdkVersion in my manifest from 8 up to 11. I needed to do this because the setX and setY methods are only available on android 3.0 and higher. But as soon as I did this, the text within my buttons was all screwed up. For a start it was white instead of black - easily fixed. But also the padding round the text was completely different. Buttons were now overlapping each other and looking unbalanced in a variety of ways.
So my question now is this: Is there any way to say "this software must only run on Android 3.0 (api 11) and above" AND "let all the text button characteristics be set to whatever that were with api level 8".
I have no idea why such things would happen - but it's better to just support the older platforms if you can help it. For example, if the only thing keeping you from using API 8+ is the setX() and setY() methods, you can use ViewHelper in the NineOldAndroids project to do this and support the lower API. For example:
ViewHelper.setX(myView, myXValue);
ViewHelper.setY(myView, myYValue);
I have requirement that , In my application I have an image that occupy the full screen,after 5 second it will slowly slide up upto 50% of the screen and stay there. Remaining 50% screen occupy another image same like it slide up from bottom to below of first image.
How I can do it?
You can start here.
There is a lot to learn on Android Animation and Graphics.
you need to use the animations API of android.
however, since the handling of animations has changed between pre-honeycomb and honeycomb, you need to decide which android versions are supported on your app.
if you have the minSdk to 11 or above, you can use the new API .
otherwise you can use the old API . you can also use the NineOldAndroids library that mimics the way the new API works, using the old API.
for both, you can look at the API demos of google (or the library i've mentioned).
so, for making the animation you've mentioned, you can use the ScaleAnimation (old API) and use the screen width as the parameters for before and after .
I have SeekBars in an application which operate as expected and return values that I expect. However, on Android 2.x they display oddly.
I've looked for other similar things such as Android Drawable setLevel(); not filling SeekBar appropriately, but that is for a custom drawable. Otherwise I'm having trouble coming up with search terms for this issue to get anywhere.
In this case, all I'm doing is
SeekBar seekBar = (SeekBar)dialogLayout.findViewById(R.id.my_seek);
seekBar.setProgress(5);
seekBar.setMax(20);
If I move the slider, it properly fills the SeekBar the moment it's moved.
Any idea on what is going on?
After posting this, I realized the problem was the order of the method calls.
Incorrect
SeekBar seekBar = (SeekBar)dialogLayout.findViewById(R.id.my_seek);
seekBar.setProgress(5);
seekBar.setMax(20);
Correct
SeekBar seekBar = (SeekBar)dialogLayout.findViewById(R.id.my_seek);
seekBar.setMax(20);
seekBar.setProgress(5);
From what I gather if you first call setProgress(5) in my case, the system will set the drawable to display the progress as 5% since it is 5 / 100 and 100 is the default maximum.
Then if you call setMax(20), the value of 5 is still valid but the drawable is no longer valid and is not recalculated to display as 25% (5 / 20) of the bar.
Doing setMax(20) first will compel the drawable to be calculated correctly once you use setProgress(5).
In case it's of use to anyone, I tested this on Android 2.1, 2.2, 4.1 and 4.2.
Android 2.1 and 2.2 have this bug, the order matters
Android 4.1 and 4.2 do not have this bug, the order doesn't matter
Essentially to remain backwards compatible, always do setMax(int) first and then setProgress(int).