Brief introduction
I believe everyone has used various layouts, and for various layouts will be used to set the background image this function
Android phones are mostly on the market at 4.4.4 or above, but older phones still exist.
So for Android compatibility issues, we still have to take care of.
Treatment Scenarios
How do we deal with Android compatibility issues?
根本:就是对sdk版本所缺少的类或者方法做出相应处理即可
Case analysis
Example one: SetBackground
相信大家都或多或少的使用过,如:LinearLayout.setBackgroud(Drawable background) 但是有没有发现问题?
/** * Set the background to a given drawable, or remove the background. If the * background has padding, this View ' s padding are set to the background ' s * padding. However, when a background was removed, this View ' s padding isn ' t * touched. If setting the padding is desired, please use * {@link #setPadding (int, int, int, int)}. * * @param background The drawable to use as the background, or null to remove the * background */ Public void SetBackground(drawable background) {//noinspection DeprecationSetbackgrounddrawable (background); }/** * @deprecated Use {@link #setBackground (drawable)} instead */ @Deprecated Public void setbackgrounddrawable(drawable background) {
@Deprecated found that the call to Setbackgrounddrawable is actually out of date, it is not recommended to use this method
Use Android Studio's windows+f2 to see the following information
This means that this method is only possible after API 16.
That's the way Android 4.1 Jelly beans (API level 16)
If the phone before this, call this method, there will be a nosuchmethoderror error
So if you use this method to do compatible processing, of course, you can also use the Setbackgroundresource method instead of
This method starts with API 1, so don't worry about it.
For example two: Android 6.0 Delete HttpClient related class resolution also to be resolved etc. ....
解决方案:[http://blog.csdn.net/yangqingqo/article/details/48214865](http://blog.csdn.net/yangqingqo/article/details/48214865)
The above is setbackground compatibility problem, solve, of course, there are many other problems, for the time being not an example, met, in leaf out can be directly resolved, thanks.
Android Compatibility Introduction SetBackground