Is there a way to use View animation methods previous to API 11? I know about the Support v4 library but I can't figure out how to use it, so I can't tell if a solution is in there. I want to be able to execute a line like that below in earlier versions:
activeAnimator = sliderHolder.Animate().TranslationX(newX).SetDuration(500).SetListener(new SlideFinishListener(this));
Have a look at NineOldAndroids, which provides all of the same functionality and API that the HoneyComb+ APIs do.
Related
I'm developing an app, and I need to animate some simple stuff, I manage to did it by using the Transition Framework, however it is not supported in android versions prior KITKAT(API LEVEL 19), I would like to know some alternatives to make some simple transitions in older devices, thank you.
You can use the following libraries:
TransitionsBackport
transitions-everywhere
SmoothTransition
PreLollipopTransition
android-transition
Google recently added the SwipeRefreshLayout to the support library.
What's the most straightforward and proper way to be able to use this in an app that is targeting API level 14 that has previously been using the regular APIs for things like fragments?
Since it's in the support library, you can simply include the library and use it. If you are referring to whether or not it can work with native Fragment instead of Fragment provided by the support library, it can.
It basically is just a decorator over a ListView or a ScrollView, you can follow the tutorial here: http://antonioleiva.com/swiperefreshlayout/
I am new to Android development and I am following the training at http://developer.android.com to get into it. I am confused whether I do use the support library or not.
To make it clear: I do not need to support APIs older than 11.
Situation: Adding Items to the ActionBar I had to use my own Namespace to make it work (app:showAsAction="ifRoom" instead of android:showAsAction="ifRoom"), which is a normal behaviour using the support-lib, am I right?
First Question: Why am I using it? I did never activate it on purpose!
Second Question:
Is it normal that I can use both getActionBar().setDisplayHomeAsUpEnabled(true); and getSupportActionBar().setDisplayHomeAsUpEnabled(true); to make the "up"-functionality work? I thought the first one wouldn't work if I used the support-lib?
I'd be glad if one of you could help me. I don't want to mess around with these basics so I'd like to know what I understood or configured wrong.
EDIT: My "uses-sdk" in the AndroidManifest actually looks like this:
<uses-sdk android:minSdkVersion="11" android:targetSdkVersion="19" />
To answer your first question, depending on how you created your project in the first place, it was probably enabled for you automatically. There are lots of other things in the support library besides ActionBar, so even if your minSdkVersion=11, it's probably still a good idea to use it.
To answer your second question, yes, it's normal that both methods work. Framework methods are not disabled or removed when you enable the support library. They will still work as long as they are supported by the Android OS you're eventually running on. For example, if your minSdkVersion was 10 instead of 11 and you tried to run the app on a device running Gingerbread, it would crash on the getActionBar() call.
In your case, you should use the framework method (getActionBar()). The documentation for ActionBar says:
This class is included in the support library for compatibility with
API level 7 and higher. If you're developing your app for API level 11
and higher only, you should instead use the framework ActionBar
class.
The best way to know whether you need to use the support library for a given method or class is to refer to the documentation for that class and pay attention to the "Added in API Level ?" notation. Here is the documentation non-support-library version of ActionBar, where you can see that some methods were added after API 11. If you need any of those methods, you should use the support library.
Also, as I said before, there other things besides ActionBar to consider in your app. GridLayout is an example. It was added in API 14, but it also exists in the support library for backwards compatibility. If you want to use GridLayout, you should use the support library version of it.
I have a very basic question.
I have a project which has minSDKVersion set to 8 and targetSDK version as 16. Now one of the methods I used setActionView() using this link.
requires a min API level of 11.
I just want to know if it'll work in version 2.2 or not??
Or if there is a way to support previous devices?I want to use collapsible action item which requires the use of 'setActionView()'. Is there any other way to use this?
If it says this feature requires a minimum API level that is greater than what you set in your manifest, you will have trouble using this feature in these older devices. But check Android support library. This may help you support these devices.
if you are using MenuItem com.actionbarsherlock.view.MenuItem.setActionView(View view) then the support for the same should be there in library and will work on 2.2 .
You may also want to check out ActionBarCompat, to give you this functionality... (see this link)
When using android appcompact actionbar library, you could use setActionView with SupportMenuItem.So your code should be like
private SupportMenuItem menuItem=(SupportMenuItem) menu.findItem(R.id.menu_refresh);
menuItem.setActionView(R.layout.progressbar);
You can do it like this with the support library:
MenuItemCompat.setActionView(yourMenuItem, R.layout.your_view);
I am in the process of making my application compatible with the earlier versions of android using the Android Compatibility library. One of the integral parts of my application is to be able to highlight the user's selection permanently in a list fragment. I was able to do this conveniently using a selector drawable in API level 11 and above using the android:state_activated property. But as it turns out this property was introduced only in API level 11.
Now I plan to achieve the same in earlier API levels, but am out of ideas. Does anyone have any suggestions?
I believe I'll need to create a separate layout for older API versions - res/layout-v10/
Thanks!
Found an excellent solution here: http://udinic.wordpress.com/2011/07/01/selectablelistview-make-selection-work/
View.setSelected(boolean) (since api level 1) made the trick for me