Support Library官方教程(3)android studio中导入支援包
Support Library Setup
How you setup the Android Support Libraries in your development project depends on what features you want to use and what range of Android platform versions you want to support with your application.
This document guides you through downloading the Support Library package and adding libraries to your development environment.
Downloading the Support Libraries
The Android Support Library package is provided as a supplemental download to the Android SDK and is available through the Android SDK Manager. Follow the instructions below to obtain the Support Library files.
To download the Support Library through the SDK Manager:
- Start the Android SDK Manager.
- In the SDK Manager window, scroll to the end of the Packages list, find theExtras folder and, if necessary, expand to show its contents.
- Select the Android Support Library item.
Note: If you're developing with Android Studio, select and install the Android Support Repository item instead.
- Click the Install packages... button.

Figure 1. The Android SDK Manager with the Android Support Library selected.
After downloading, the tool installs the Support Library files to your existing Android SDK directory. The library files are located in the following subdirectory of your SDK: <sdk>/extras/android/support/ directory.
Choosing Support Libraries
Before adding a Support Library to your application, decide what features you want to include and the lowest Android versions you want to support. For more information on the features provided by the different libraries, see Support Library Features.
Adding Support Libraries
In order to use a Support Library, you must modify your application's project's classpath dependencies within your development environment. You must perform this procedure for each Support Library you want to use.
Some Support Libraries contain resources beyond compiled code classes, such as images or XML files. For example, the v7 appcompat and v7 gridlayout libraries include resources.
保用支援包时要反它们导入项目中,而有些支援包有资源文件,也要把它们导入。如v7 appcompat和 v7 girdlayout就有资源文件
If you are not sure if a library contains resources, check the Support Library Features page. The following sections describe how to add a Support Library with or without resources to your application project.
Adding libraries without resources(无资源文件支援包的导入步骤)
To add a Support Library without resources to your application project:
- Make sure you have downloaded the Android Support Repository using the SDK Manager.
- Open the
build.gradlefile for your application. - Add the support library to the
dependenciessection. For example, to add the v4 support library, add the following lines:dependencies {
...
compile "com.android.support:support-v4:18.0.+"
}
Adding libraries with resources(有资源文件支援包的导入步骤)
To add a Support Library with resources (such as v7 appcompat for action bar) to your application project:
- Make sure you have downloaded the Android Support Repository using the SDK Manager.
- Open the
build.gradlefile for your application. - Add the support library feature project identifier to the
dependenciessection. For example, to include theappcompatproject addcompile "com.android.support:appcompat-v7:18.0.+"to the dependencies section, as shown in the following example:dependencies {
...
compile "com.android.support:appcompat-v7:18.0.+"
}
Using Support Library APIs
Support Library classes that provide support for existing framework APIs typically have the same name as framework class but are located in the android.support class packages, or have a *Compat suffix.
支援包中的类多在android.support中,或以 *Compat 为后缀
Caution: When using classes from the Support Library, be certain you import the class from the appropriate package. For example, when applying the ActionBar class:
android.support.v7.app.ActionBarwhen using the Support Library.android.app.ActionBarwhen developing only for API level 11 or higher.
Note: After including the Support Library in your application project, we strongly recommend using the ProGuard tool to prepare your application APK for release. In addition to protecting your source code, the ProGuard tool also removes unused classes from any libraries you include in your application, which keeps the download size of your application as small as possible. For more information, see ProGuard.
如果使用了支援包,通常要生成发布版的apk时,要用ProGuard优化,混淆,减少apk的体积。
Further guidance for using some Support Library features is provided in the Android developer training classes, guides and samples. For more information about the individual Support Library classes and methods, see the android.support packages in the API reference.
Manifest Declaration Changes
If you are increasing the backward compatibility of your existing application to an earlier version of the Android API with the Support Library, make sure to update your application's manifest. Specifically, you should update the android:minSdkVersion element of the <uses-sdk> tag in the manifest to the new, lower version number, as shown below:
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="17" />
The manifest setting tells Google Play that your application can be installed on devices with Android 2.1 (API level 7) and higher.
If you are using Gradle build files, the minSdkVersion setting in the build file overrides the manifest settings.
apply plugin: 'com.android.application'
android {
...
defaultConfig {
minSdkVersion 8
...
}
...
}
In this case, the build file setting tells Google Play that the default build variant of your application can be installed on devices with Android 2.2 (API level 8) and higher. For more information about build variants, see Build System Overview.
Note: If you are including the v4 support and v7 appcompat libraries in your application, you should specify a minimum SDK version of "7" (and not "4"). The highest support library level you include in your application determines the lowest API version in which it can operate.
Code Samples(示例的位置)
Each Support Library includes code samples to help you get started using the support APIs. The code is included in the download from the SDK Manager and is placed inside the Android SDK installation directory, as listed below:
- 4v Samples:
<sdk>/extras/android/support/samples/Support4Demos/ - 7v Samples:
<sdk>/extras/android/support/samples/Support7Demos/ - 13v Samples:
<sdk>/extras/android/support/samples/Support13Demos/ - App Navigation:
<sdk>/extras/android/support/samples/SupportAppNavigation/
Support Library官方教程(3)android studio中导入支援包的更多相关文章
- 在Android Studio中导入jar包
#1 下载jar包文件, #2 拷贝到libs目录下 #3 打开你的build.gradle,在dependencies加入如下代码 dependencies {compile files('libs ...
- Support Library官方教程(2)各支援包的特性详介(含表)*
快速阅读 包名 作用 位置 是否有资源 v4 提供了最多的api <sdk>/extras/android/support/v4/ y Multidex 把DEX文件生成apk < ...
- Android Studio中导入第三方库
之前开发Android都是使用的eclipse,近期因为和外国朋友Timothy一起开发一款应用,他是从WP平台刚切换使用Android的,使用的开发环境时Android Studio,为了便于项目的 ...
- Android studio中导入第三方类库
常常在github上看到一些好用的框架,但是对于一个新手怎样在android studio上导入去总会遇到各种麻烦,索性来研究下第三方类库怎样在android studio上导入. 以我在github ...
- Android如何使用so文件和Android studio中导入so
Android中使用so文件: 做一个PDF阅读的功能,找到一个开源的库,mupdf.下载的是网上编译好的so库,导入到自己项目中的时候一直报错Java.lang.UnsatisfiedLinkErr ...
- Support Library官方教程(1)概述
Support Library The Android Support Library package is a set of code libraries that provide backward ...
- 在android studio中导入github下载的工程
1.从Github中下载工程压缩包,并将其解压到本地 2.修改文件 假设,解压后的文件目录如下: (1)修改配置文件 xx\build.gradle // Top-level build file ...
- Android Studio中导入v4,v7和recyclerview-v7包的方法
概述 Android Studio中新建工程中会默认导入v7的包,即在gradle中默认配置了com.android.support:appcompat-v7:x.x.x的依赖.但是不会默认为我们配置 ...
- 关于Android Studio中第三方jar包的Javadoc绑定
原文地址:http://blog.csdn.net/a739697044/article/details/28116189 现在刚开始从Eclipse转用Android Studio,现在在尝试使 ...
随机推荐
- Android中解析JSON形式的数据
1.JSON(JavaScript Object Notation) 定义: 一种轻量级的数据交换格式,具有良好的可读和便于快速编写的特性.业内主流技术为其提供了完整的解决方案(有点类似于正则表达式, ...
- Sybase ASE报错:server Error: 8242, Severity: 16, State: 1
昨天上午,同事反映某系统在执行存储过程的过程中报错了,报错的信息异常如下: 05:00000:00009:2014/06/09 15:45:30.34 server Error: 8242, Seve ...
- linux编码
转: Linux查看文件编码格式及文件编码转换 如果你需要在Linux中操作windows下的文件,那么你可能会经常遇到文件编码转换的问题.Windows中默认的文件格式是GBK(gb2312),而L ...
- 构件图 Component Diagram
构件图是显示代码自身结构的实现级别的图表.构件图由诸如源代码文件.二进制代码文件.可执行文件或动态链接库 (DLL) 这样的构件构成,并通过依赖关系相连接 下面这张图介绍了构件图的基本内容: 下面这张 ...
- C#更改控制台文本颜色
C#更改控制台文本的前景色和背景色 关键字:C# NET 控制台 前景色 背景色地址:http://www.cnblogs.com/txw1958/archive/2012/12/07/cshar ...
- MS SQL Server中的CONVERT日期格式化大全
CONVERT 将某种数据类型的表达式显式转换为另一种数据类型.由于某些需求经常用到取日期格式的不同. 现以下可在SQL Server中将日期格式化. SQL Server 支持使用科威特算法的阿拉伯 ...
- execvp使用实例
问题描述: 本程序实现模拟shell功能,用户输入命令,返回相应的结果 问题解决: 注: 以上指出了execvp函数的使用,使用时第一个参数是文件名,第二个参数是一个 ...
- Vim安装ctags插件
问题描述: 系统安装ctags插件 问题解决: (1)下载ctags插件 (2)新下载的ctags文件是一个tar包文件,使用tar -zxcf命令进行解压缩 注: 解压缩之后的 ctags文件,如上 ...
- Bootstrap 基础
一种前端开发框架,如同YUI 下载源码找开后,其文件结构如下: bootstrap/├── css/│ ├── bootstrap.css│ ├── bootstrap.min.css│ ...
- 你真的知道css三种存在样式(外联样式、内部样式、内联样式)的区别吗?
css样式在html中有三种存在形态: 内联样式:<div style="display: none"></div> 内部样式: <style> ...