当前位置: 首页 > 编程日记 > 正文

Android官方提供的支持不同屏幕大小的全部方法

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

本文将告诉你如何让你的应用程序支持各种不同屏幕大小,主要通过以下几种办法:

  • 让你的布局能充分的自适应屏幕

  • 根据屏幕的配置来加载合适的UI布局

  • 确保正确的布局应用在正确的设备屏幕上

  • 提供可以根据屏幕大小自动伸缩的图片

使用 "wrap_content" 和 "match_parent"

为了确保你的布局能够自适应各种不同屏幕大小,你应该在布局的视图中使用"wrap_content""match_parent"来确定它的宽和高。如果你使用了"wrap_content",相应视图的宽和高就会被设定成刚好能够包含视图中内容的最小值。而如果你使用了"match_parent"(在Android API 8之前叫作"fill_parent"),就会让视图的宽和高延伸至充满整个父布局。

通过使用"wrap_content""match_parent"来替代硬编码的方式定义视图大小,你的视图要么仅仅使用了需要的那边一点空间,要么就会充满所有可用的空间。例如:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"android:layout_width="match_parent"android:layout_height="match_parent"><LinearLayout android:layout_width="match_parent" android:id="@+id/linearLayout1"  android:gravity="center"android:layout_height="50dp"><ImageView android:id="@+id/imageView1" android:layout_height="wrap_content"android:layout_width="wrap_content"android:src="@drawable/logo"android:paddingRight="30dp"android:layout_gravity="left"android:layout_weight="0" /><View android:layout_height="wrap_content" android:id="@+id/view1"android:layout_width="wrap_content"android:layout_weight="1" /><Button android:id="@+id/categorybutton"android:background="@drawable/button_bg"android:layout_height="match_parent"android:layout_weight="0"android:layout_width="120dp"style="@style/CategoryButtonStyle"/></LinearLayout><fragment android:id="@+id/headlines" android:layout_height="fill_parent"android:name="com.example.android.newsreader.HeadlinesFragment"android:layout_width="match_parent" />
</LinearLayout>

注意上面的例子中是如何使用 "wrap_content"  "match_parent" 来给控件定义宽高的,这让整个布局可以正确地适应不同屏幕的大小,甚至是横屏。

下图是这个布局分别在竖屏和横屏时显示的结果,注意控件的宽和高是根据屏幕自适应的。

Android官方提供的支持不同屏幕大小的全部方法

使用RelativeLayout

通过多层嵌套LinearLayout和组合使用"wrap_content""match_parent"已经可以构建出足够复杂的布局。但是LinearLayout无法允许你准确地控制子视图之前的位置关系,所有LinearLayout中的子视图只能简单的一个挨着一个地排列。如果你需要让子视图能够有更多的排列方式,而不是简单地排成一行或一列,使用RelativeLayout将会是更好的解决方案。RelativeLayout允许布局的子控件之间使用相对定位的方式控制控件的位置,比如你可以让一个子视图居屏幕左侧对齐,让另一个子视图居屏幕右侧对齐。

例如:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"><TextViewandroid:id="@+id/label"android:layout_width="match_parent"android:layout_height="wrap_content"android:text="Type here:"/><EditTextandroid:id="@+id/entry"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_below="@id/label"/><Buttonandroid:id="@+id/ok"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@id/entry"android:layout_alignParentRight="true"android:layout_marginLeft="10dp"android:text="OK" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_toLeftOf="@id/ok"android:layout_alignTop="@id/ok"android:text="Cancel" />
</RelativeLayout>

下图展示了这个布局在QVGA屏幕上显示的结果。

Android官方提供的支持不同屏幕大小的全部方法

下图展示了这个布局在一个更大的屏幕上显示的结果。

Android官方提供的支持不同屏幕大小的全部方法

可以注意到,即使屏幕的大小改变,视图之前的相对位置都没有改变。

使用Size限定符

虽然使用以上几种方式可以解决屏幕适配性的问题,但是那些通过伸缩控件来适应各种不同屏幕大小的布局,未必就是提供了最好的用户体验。你的应用程序应该不仅仅实现了可自适应的布局,还应该提供一些方案根据屏幕的配置来加载不同的布局,可以通过配置限定符(configuration qualifiers)来实现。配置限定符允许程序在运行时根据当前设备的配置自动加载合适的资源(比如为不同尺寸屏幕设计不同的布局)。

现在有很多的应用程序为了支持大屏设备,都会实现“two pane”模式(程序会在左侧的面板上展示一个包含子项的List,在右侧面板上展示内容)。平板和电视设备的屏幕都很大,足够同时显示两个面板,而手机 屏幕一次只能显示一个面板,两个面板需要分开显示。所以,为了实现这种布局,你可能需要以下文件:

res/layout/main.xml,single-pane(默认)布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  android:orientation="vertical"  android:layout_width="match_parent"  android:layout_height="match_parent">  <fragment android:id="@+id/headlines"  android:layout_height="fill_parent"  android:name="com.example.android.newsreader.HeadlinesFragment"  android:layout_width="match_parent" />  
</LinearLayout>

res/layout-large/main.xml ,two-pane布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  android:layout_width="fill_parent"  android:layout_height="fill_parent"  android:orientation="horizontal">  <fragment android:id="@+id/headlines"  android:layout_height="fill_parent"  android:name="com.example.android.newsreader.HeadlinesFragment"  android:layout_width="400dp"  android:layout_marginRight="10dp"/>  <fragment android:id="@+id/article"  android:layout_height="fill_parent"  android:name="com.example.android.newsreader.ArticleFragment"  android:layout_width="fill_parent" />  
</LinearLayout>

请注意第二个布局的目录名中包含了large限定符,那些被定义为大屏的设备(比如7寸以上的平板)会自动加载此布局,而小屏设备会加载另一个默认的布局。

使用Smallest-width限定符

使用Size限定符有一个问题会让很多程序员感到头疼,large到底是指多大呢?很多应用程序都希望能够更自由地为不同屏幕设备加载不同的布局,不管它 们是不是被系统认定为"large"。这就是Android为什么在3.2以后引入了"Smallest-width"限定符。

Smallest-width限定符允许你设定一个具体的最小值(以dp为单位)来指定屏幕。例如,7寸的平板最小宽度是600dp,所以如果你想让你的UI在这种屏幕上显示two pane,在更小的屏幕上显示single pane,你可以使用sw600dp来表示你想在600dp以上宽度的屏幕上使用two pane模式。

res/layout/main.xml,single-pane(默认)布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  android:orientation="vertical"  android:layout_width="match_parent"  android:layout_height="match_parent">  <fragment android:id="@+id/headlines"  android:layout_height="fill_parent"  android:name="com.example.android.newsreader.HeadlinesFragment"  android:layout_width="match_parent" />  
</LinearLayout>

res/layout-sw600dp/main.xml ,two-pane布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  android:layout_width="fill_parent"  android:layout_height="fill_parent"  android:orientation="horizontal">  <fragment android:id="@+id/headlines"  android:layout_height="fill_parent"  android:name="com.example.android.newsreader.HeadlinesFragment"  android:layout_width="400dp"  android:layout_marginRight="10dp"/>  <fragment android:id="@+id/article"  android:layout_height="fill_parent"  android:name="com.example.android.newsreader.ArticleFragment"  android:layout_width="fill_parent" />  
</LinearLayout>


这意味着,那些最小屏幕宽度大于600dp的设备会选择 layout-sw600dp/main.xml (two-pane)布局,而更小屏幕的设备将会选择 layout/main.xml (single-pane)布局。

然而,使用早于Android 3.2系统的设备将无法识别sw600dp这个限定符,所以你还是同时需要使用large限定符。这样你就需要在res/layout-largeres/layout-sw600dp目录下都添加一个相同的main.xml。下节你将会看到如何避免重复定义这种布局的技巧。

使用布局别名

Smallest-width限定符仅在Android 3.2及之后的系统中有效。因而,你也需要同时使用Size限定符(small, normal, large和xlarge)来兼容更早的系统。例如,你想手机上显示single-pane界面,而在7寸平板和更大屏的设备上显示multi-pane 界面,你需要提供以下文件:

  • res/layout/main.xml: single-pane布局

  • res/layout-large: multi-pane布局

  • res/layout-sw600dp: multi-pane布局

最后的两个文件是完全相同的,为了要解决这种重复,你需要使用别名技巧。例如,你可以定义以下布局:

  • res/layout/main.xml, single-pane布局

  • res/layout/main_twopanes.xml, two-pane布局

加入以下两个文件:

res/values-large/layout.xml:

<resources>  <item name="main" type="layout">@layout/main_twopanes</item>  
</resources>

res/values-sw600dp/layout.xml: 

<resources>  <item name="main" type="layout">@layout/main_twopanes</item>  
</resources>

最后两个文件有着相同的内容,但是它们并没有真正去定义布局,它们仅仅只是给main定义了一个别名main_twopanes。这样两个layout.xml都只是引用了@layout/main_twopanes,就避免了重复定义布局文件的情况。

使用Orientation限定符

有些布局会在横屏和竖屏的情况下都显示的很好,但是多数情况下这些布局都可以再调整的。在News Reader示例程序中,布局在不同屏幕尺寸和不同屏幕方向中是这样显示的:

  • 小屏幕, 竖屏: 单面板, 显示logo

  • 小屏幕, 横屏: 单面板, 显示logo

  • 7寸平板, 竖屏: 单面板, 显示action bar

  • 7寸平板, 横屏: 双面板, 宽, 显示action bar

  • 10寸平板, 竖屏: 双面板, 窄, 显示action bar

  • 10寸平板, 横屏: 双面板, 宽, 显示action bar

  • 电视, 横屏: 双面板, 宽, 显示action bar

所有这些布局都是定义在 res/layout/ 这个目录下,为了要让设备根据屏幕配置来加载正确的布局,程序需要使用布局别名来实现。

res/layout/onepane.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  android:orientation="vertical"  android:layout_width="match_parent"  android:layout_height="match_parent">  <fragment android:id="@+id/headlines"  android:layout_height="fill_parent"  android:name="com.example.android.newsreader.HeadlinesFragment"  android:layout_width="match_parent" />  
</LinearLayout>


res/layout/onepane_with_bar.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  android:orientation="vertical"  android:layout_width="match_parent"  android:layout_height="match_parent">  <LinearLayout android:layout_width="match_parent"   android:id="@+id/linearLayout1"    android:gravity="center"  android:layout_height="50dp">  <ImageView android:id="@+id/imageView1"   android:layout_height="wrap_content"  android:layout_width="wrap_content"  android:src="@drawable/logo"  android:paddingRight="30dp"  android:layout_gravity="left"  android:layout_weight="0" />  <View android:layout_height="wrap_content"   android:id="@+id/view1"  android:layout_width="wrap_content"  android:layout_weight="1" />  <Button android:id="@+id/categorybutton"  android:background="@drawable/button_bg"  android:layout_height="match_parent"  android:layout_weight="0"  android:layout_width="120dp"  style="@style/CategoryButtonStyle"/>  </LinearLayout>  <fragment android:id="@+id/headlines"   android:layout_height="fill_parent"  android:name="com.example.android.newsreader.HeadlinesFragment"  android:layout_width="match_parent" />  
</LinearLayout>

res/layout/twopanes.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  android:layout_width="fill_parent"  android:layout_height="fill_parent"  android:orientation="horizontal">  <fragment android:id="@+id/headlines"  android:layout_height="fill_parent"  android:name="com.example.android.newsreader.HeadlinesFragment"  android:layout_width="400dp"  android:layout_marginRight="10dp"/>  <fragment android:id="@+id/article"  android:layout_height="fill_parent"  android:name="com.example.android.newsreader.ArticleFragment"  android:layout_width="fill_parent" />  
</LinearLayout>

res/layout/twopanes_narrow.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  android:layout_width="fill_parent"  android:layout_height="fill_parent"  android:orientation="horizontal">  <fragment android:id="@+id/headlines"  android:layout_height="fill_parent"  android:name="com.example.android.newsreader.HeadlinesFragment"  android:layout_width="200dp"  android:layout_marginRight="10dp"/>  <fragment android:id="@+id/article"  android:layout_height="fill_parent"  android:name="com.example.android.newsreader.ArticleFragment"  android:layout_width="fill_parent" />  
</LinearLayout>

现在所有需要的布局都已经定义好了,剩下的只要使用限定符来让各个设备根据屏幕配置加载正确的布局了。你现在就可以使用布局别名技术:

res/values/layouts.xml:

<resources>  <item name="main_layout" type="layout">@layout/onepane_with_bar</item>  <bool name="has_two_panes">false</bool>  
</resources>

res/values-sw600dp-land/layouts.xml:

<resources>  <item name="main_layout" type="layout">@layout/twopanes</item>  <bool name="has_two_panes">true</bool>  
</resources>

res/values-sw600dp-port/layouts.xml:

<resources>  <item name="main_layout" type="layout">@layout/onepane</item>  <bool name="has_two_panes">false</bool>  
</resources>

res/values-large-land/layouts.xml:

<resources>  <item name="main_layout" type="layout">@layout/twopanes</item>  <bool name="has_two_panes">true</bool>  
</resources>

res/values-large-port/layouts.xml:

<resources>  <item name="main_layout" type="layout">@layout/twopanes_narrow</item>  <bool name="has_two_panes">true</bool>  
</resources>

使用Nine-Patch图片

支持不同屏幕大小通常情况下也意味着,你的图片资源也需要有自适应的能力。例如,一个按钮的背景图片必须能够随着按钮大小的改变而改变。

如果你想使用普通的图片来实现上述功能,你很快就会发现结果是令人失望的,因为运行时会均匀地拉伸或压缩你的图片。解决方案是使用nine-patch图片,它是一种被特殊处理过的PNG图片,你可以指定哪些区域可以拉伸而哪些区域不可以。

因而,当你设计需要在不同大小的控件中使用的图片时,最好的方法就是用nine-patch图片。为了将图片转换成nine-patch图片,你可以从一张普通的图片开始:

Android官方提供的支持不同屏幕大小的全部方法

然后通过SDK中带有的draw9patch工具打开这张图片(工具位置在SDK的tools目录下),你可以在图片的左边框和上边框绘制来标记哪些区域可以被拉伸。你也可以在图片的右边框和下边框绘制来标记内容需要放置在哪个区域。结果如下图所示:

Android官方提供的支持不同屏幕大小的全部方法

注意图片边框上的黑色像素,在上边框和左边框的部分表示当图片需要拉伸时就拉伸黑点标记的位置。在下边框和右边框的部分表示内容将会被放置的区域。

同时需要注意,这张图片的后缀名是 .9.png。你必须要使用这个后缀名,因为系统就是根据这个来区别nine-patch图片和普通的PNG图片的。

当你需要在一个控件中使用nine-patch图片时(如android:background="@drawable/button"),系统就会根据控件的大小自动地拉伸你想要拉伸的部分,效果如下图所示:

Android官方提供的支持不同屏幕大小的全部方法


转载于:https://my.oschina.net/onlytwo/blog/229400

相关文章:

C++/C++11中头文件iterator的使用

<iterator>是C标准程序库中的一个头文件&#xff0c;定义了C STL标准中的一些迭代器模板类&#xff0c;这些类都是以std::iterator为基类派生出来的。迭代器提供对集合(容器)元素的操作能力。迭代器提供的基本操作就是访问和遍历。迭代器模拟了C中的指针&#xff0c;可以…

从多媒体技术演进看AI技术

&#xff08;图片付费下载自视觉中国&#xff09;文 / LiveVideoStack主编 包研在8月的LiveVideoStackCon2019北京开场致辞中&#xff0c;我分享了一组数据——把2019年和2017年两场LiveVideoStackCon上的AI相关的话题做了统计&#xff0c;这是数字从9.3%增长到31%&#xff0c;…

五. python的日历模块

一 .日历 import calendar# 日历模块# 使用# 返回指定某年某月的日历 print(calendar.month(2017,7))# July 2017 # Mo Tu We Th Fr Sa Su # 1 2 # 3 4 5 6 7 8 9 # 10 11 12 13 14 15 16 # 17 18 19 20 21 22 23 # 24 25 26 27 28 29 30 # 31# 返…

Linux下的Shell工作原理

为什么80%的码农都做不了架构师&#xff1f;>>> Linux系统提供给用户的最重要的系统程序是Shell命令语言解释程序。它不 属于内核部分&#xff0c;而是在核心之外&#xff0c;以用户态方式运行。其基本功能是解释并 执行用户打入的各种命令&#xff0c;实现用户与L…

C++/C++11中头文件functional的使用

<functional>是C标准库中的一个头文件&#xff0c;定义了C标准中多个用于表示函数对象(function object)的类模板&#xff0c;包括算法操作、比较操作、逻辑操作&#xff1b;以及用于绑定函数对象的实参值的绑定器(binder)。这些类模板的实例是具有函数调用运算符(functi…

飞天AI平台到底哪里与众不同?听听它的架构者怎么说

采访嘉宾 | 林伟 整理 | 夕颜 出品 | AI科技大本营&#xff08;ID:rgznai100&#xff09; 天下没有不散的宴席。 9 月 25 日&#xff0c;云栖大会在云栖小镇开始&#xff0c;历经三天的技术盛宴&#xff0c;于 9 月 27 日的傍晚结束。 三天、全球6.7万人现场参会、超1250万人…

浅谈 sessionStorage、localStorage、cookie 的区别以及使用

1、sessionStorage、localStorage、cookie 之间的区别 相同点 cookie 和 webStorage 都是用来存储客户端的一些信息不同点 localStorage localStorage 的生命周期是 永久的。也就是说 只要不是 手动的去清除。localStorage 会一直存储 sessionStorage 相反 sessionStorage 的生…

任务栏窗口和状态图标的闪动 z

Demo程序&#xff1a; 实现任务栏窗体和图标的闪动&#xff1a; 整个程序是基于Windows Forms的&#xff0c;对于任务栏右下角状态图标的闪动&#xff0c;创建了一个类型&#xff1a;NotifyIconAnimator&#xff0c;基本上是包装了Windows Forms中的NotifyIcon类型&#xff0c;…

深度学习中的最大似然估计简介

统计领域为我们提供了很多工具来实现机器学习目标&#xff0c;不仅可以解决训练集上的任务&#xff0c;还可以泛化。例如参数估计、偏差和方差&#xff0c;对于正式地刻画泛化、欠拟合和过拟合都非常有帮助。点估计&#xff1a;点估计试图为一些感兴趣的量提供单个”最优”预测…

简单粗暴上手TensorFlow 2.0,北大学霸力作,必须人手一册!

&#xff08;图片付费下载自视觉中国&#xff09; 整理 | 夕颜 出品 | AI科技大本营&#xff08;ID:rgznai100&#xff09; 【导读】 TensorFlow 2.0 于近期正式发布后&#xff0c;立即受到学术界与科研界的广泛关注与好评。此前&#xff0c;AI 科技大本营曾特邀专家回顾了 Te…

常见运维漏洞-Rsync-Redis

转载于:https://blog.51cto.com/10945453/2394651

zabbix笔记

&#xff08;1&#xff09;转载于:https://blog.51cto.com/zlong37/1406441

C++/C++11中头文件algorithm的使用

<algorithm>是C标准程序库中的一个头文件&#xff0c;定义了C STL标准中的基础性的算法(均为函数模板)。<algorithm>定义了设计用于元素范围的函数集合。任何对象序列的范围可以通过迭代器或指针访问。 std::adjacent_find&#xff1a;在序列中查找第一对相邻且值…

js filter 用法

filter filter函数可以看成是一个过滤函数&#xff0c;返回符合条件的元素的数组 filter需要在循环的时候判断一下是true还是false&#xff0c;是true才会返回这个元素&#xff1b; filter()接收的回调函数&#xff0c;其实可以有多个参数。通常我们仅使用第一个参数&#xff…

每30秒学会一个Python小技巧,GitHub星数4600+

&#xff08;图片付费下载自视觉中国&#xff09;作者 | xiaoyu&#xff0c;数据爱好者来源 | Python数据科学&#xff08;ID:PyDataScience&#xff09;很多学习Python的朋友在项目实战中会遇到不少功能实现上的问题&#xff0c;有些问题并不是很难的问题&#xff0c;或者已经…

Nginx自定义模块编写:根据post参数路由到不同服务器

Nginx可以轻松实现根据不同的url 或者 get参数来转发到不同的服务器&#xff0c;然而当我们需要根据http包体来进行请求路由时&#xff0c;Nginx默认的配置规则就捉襟见肘了&#xff0c;但是没关系&#xff0c;Nginx提供了强大的自定义模块功能&#xff0c;我们只要进行需要的扩…

深度学习中的贝叶斯统计简介

贝叶斯用概率反映知识状态的确定性程度。数据集能够被直接观测到&#xff0c;因此不是随机的。另一方面&#xff0c;真实参数θ是未知或不确定的&#xff0c;因此可以表示成随机变量。在观察到数据前&#xff0c;我们将θ的已知知识表示成先验概率分布(prior probability distr…

少走弯路:强烈推荐的TensorFlow快速入门资料(可下载)

&#xff08;图片付费下载自视觉中国&#xff09;作者 | 黄海广来源 | 机器学习初学者&#xff08;ID: ai-start-com&#xff09;知识更新非常快&#xff0c;需要一直学习才能跟上时代进步&#xff0c;举个例子&#xff1a;吴恩达老师在深度学习课上讲的TensorFlow使用&#xf…

有状态bean与无状态bean

在学习bean的作用域的时候&#xff0c;了解了这个问题。 bean5种作用域&#xff1a;分别是&#xff1a;singleton、prototype、request、session、gloabal session 接下来就讲一下有状态bean与无状态bean&#xff1a; 有状态会话bean &#xff1a;每个用户有自己特有的一个实例…

从Developer Removed From Sale 回到可下载状态的方法

2019独角兽企业重金招聘Python工程师标准>>> 如果你不小心点了”Remove“ 按钮&#xff0c;App的状态会变成"Developer Removed From Sale "&#xff0c;这时&#xff0c;即使更新应用也无法改变这个状态。想要让App恢复可下载状态&#xff0c;你需要尝试…

朴素贝叶斯分类器简介及C++实现(性别分类)

贝叶斯分类器是一种基于贝叶斯定理的简单概率分类器。在机器学习中&#xff0c;朴素贝叶斯分类器是一系列以假设特征之间强(朴素)独立下运用贝叶斯定理为基础的简单概率分类器。朴素贝叶斯是文本分类的一种热门(基准)方法&#xff0c;文本分类是以词频为特征判断文件所属类别或…

你当年没玩好的《愤怒的小鸟》,AI现在也犯难了

&#xff08;图片源自百度百科&#xff09;作者 | Ekaterina Nikonova&#xff0c;Jakub Gemrot译者 | Tianyu出品 | AI科技大本营&#xff08;ID:rgznai100&#xff09;现在说起《愤怒的小鸟》游戏&#xff0c;要把人的回忆一下拉扯到差不多十年前了。它是一款当时一经推出就广…

msf反弹shell

今天回顾了一下msf反弹shell的操作&#xff0c;在这里做一下记录和分享。(&#xffe3;︶&#xffe3;)↗ 反弹shell的两种方法 第一种Msfvenom实例&#xff1a; 1、msfconsole    #启动msf 2、msfvenom -p php/meterpreter/reverse_tcp LHOST<Your IP Address> LPOR…

mysql 5.5半同步复制功能部署

安装、配置Semi-sync Replication在两台主机上安装好MySQL5.5&#xff0c;编译好的插件在目录CMAKE_INSTALL_PREFIX/lib/plugin下&#xff08;默认是/usr/local/mysql/lib/plugin&#xff09;。例如这里编译是指定CMAKE_INSTALL_PREFIX为/home/mysql/mysql&#xff0c;则有&…

Windows7/10上配置OpenCV3.3.0-Python3.6.2操作步骤

目前OpenCV无论是2.4.x还是最新的3.3.0版本&#xff0c;默认支持的都是Python 2.7版本。这里介绍下如何使OpenCV 3.3.0支持Python 3.6.2的操作步骤&#xff1a;1. 从 https://github.com/opencv/opencv/releases/tag/3.3.0 下载3.3.0.zip或opencv-3.3.0-vc14.exe&#xff0c;…

manage.py命令

一、manage.py命令选 manage.py是每个Django项目中自动生成的一个用于管理项目的脚本文件&#xff0c;需要通过python命令执行。manage.py接受的是Django提供的内置命令。 内置命令包含 checkdbshelldiffsettingsflushmakemigrationsmigraterunservershellstartappstartproject…

图灵奖得主Bengio再次警示:可解释因果关系是深度学习发展的当务之急

&#xff08;图片付费下载自视觉中国&#xff09;作者 | Will Knight译者 | Monanfei来源 | Wired出品 | AI科技大本营&#xff08;ID:rgznai100&#xff09;深度学习擅长在大量数据中寻找模式&#xff0c;但无法解释它们之间的关系。图灵奖获得者 Yoshua Bengio 希望改变这一状…

解决jQuery不同版同时引用的冲突

今天研发的同事在开发一个新jQuery插件时&#xff0c;遇到一个揪心的问题。平台以前使用的 jQuery版本是1.2.6&#xff0c;偶&#xff0c;天啊&#xff01;这是古代的版本啊&#xff01; 由于很多功能基于老版本&#xff0c;不能删除啊&#xff0c;同志们都懂的&#xff01; 于…

TensorFlow中的计算图

作者 | stephenDC来源 | 大数据与人工智能&#xff08;ID:ai-big-data&#xff09;1 什么是计算图&#xff1f;一个机器学习任务的核心是模型的定义以及模型的参数求解方式&#xff0c;对这两者进行抽象之后&#xff0c;可以确定一个唯一的计算逻辑&#xff0c;将这个逻辑用图表…

java设计模式-适配器模式

模式导读: 每个人都有自己不同的需要&#xff0c;每个人都有自己能够接受的不同方式&#xff0c;就像是为满足现在快速度发展的社会&#xff0c;几乎人人离不开手机的时代&#xff0c;我们也许会碰到在外出行手机电量不足的情况&#xff0c;这个时候如果你在车站&#xff0c;你…