`

ImageView 的src和android:background的区别

阅读更多

针对ImageView来说:两者都可以设置ImageView的背景。

 

src:在设置ImageView的setAlpha()时有效果。

background:在设置ImageView的setAlpha()时无效果。

 

src 是原图显示而background是放大到全屏了.

android:scaleType="center"这些属性的效果只有在src模式下有效。

分享到:
评论

相关推荐

    Android中src和background的区别详解

    ImageView中XML属性src和background的区别: background会根据ImageView组件给定的长宽进行拉伸,而src就存放的是原图的大小,不会进行拉伸。src是图片内容(前景),bg是背景,可以同时使用。 此外:scaleType只对...

    Android ImageView Src 和Background 区别

    主要介绍了Android ImageView Src 和Background 区别的相关资料,需要的朋友可以参考下

    Android实训购物车页面

    Android实训项目 ...background="@drawable/aaa" android:weightSum="1" android:layout_height="match_parent" android:layout_width="match_parent" android:orientation="vertical" xmlns:android=...

    Android购物车代码

    ...background="@drawable/aaa" android:weightSum="1" android:layout_height="match_parent" android:layout_width="match_parent" android:orientation="vertical" xmlns:android=...layout_height="153dp" android:...

    点按弹出按钮组件

    android:background="@drawable/composer_button" > <ImageView android:id="@+id/id_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent=...

    ANDROID实验报告组件布局.pdf

    <ImageView android:layout_width="wrap_content" android:layout_height="100dp" android:src="@drawable/img" android:gravity="center" android:layout_span="4"/> </TableRow> <TableRow > <TextView/> ...

    android LabelView 自定义各种效果的 label 控件

    一个可配置的迷你版轻量级 Label 辅助类,支持多种配置效果。... android:src="@mipmap/ic_launcher" android:background="#f3a212" android:layout_width="150dp" android:layout_height="100dp"/>

    九宫格牌翻转游戏demo

    android:background="#000000" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin...

    android 音乐播放器

    <item name="android:background">@color/black</item>//背景黑色 <item name="android:layout_width">wrap_content</item>//宽度为文本宽度 <item name="android:layout_height">wrap_content //高度为文本高度...

    实例解析Android ImageView的scaleType属性

    <ImageView nandroid:id=@+id/imageView android:layout_width dp android:layout_height=100dp android:src> 其中src就是引用我们需要使用的图片,其可以是存放在 assets 目录下的图片,也可以是res/draw

    高仿微信界面

    android:background="#737373" /> android:layout_width="match_parent" android:layout_height="0.7dp" android:background="#101010" /> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22...

    Android ImgView属性图文详解

    ImageView是用于界面上显示图片的控件。 属性 1、为ImageView设置图片 ①android:src=@drawable/img1; src设置图片,默认图片...③如果src和background属性同时设置,src设置的图片将在上方,background设置的图片将在

    LCRapidDevelop-master

    android:src="@mipmap/def_head"/> android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" android:layout_marginLeft="15dp" android:layout_marginTop="5dp" ...

    安卓XML位图 – BitmapDrawable的详细用法 (android:tileMode=”repeat” 失效问题)

    原来它不能设置为ImageView的src,而是应该设置为一个任意View的background。 用法: 它是来定义View的背景的,跟你电脑桌面设置壁纸一样,你可以设置为横铺,拉伸,等各种背景样式。这用法跟HTML背景的一些属性有点...

    android-gif-drawable:用于在 Android 上显示动画 GIF 的视图和可绘制对象-开源

    如果 android:src 和/或 android:background 声明的 drawable 是 GIF 文件,那么它们将被自动识别为 GifDrawables 并进行动画处理。 如果给定的 drawable 不是 GIF,那么提到的 Views 就像普通的 ImageView 和 ...

    WelcomeVideoPager-仿蚂蜂窝自由行和慕课网视频欢迎页.zip

     android:background="@mipmap/bt_start"  android:textColor="@android:color/white"  android:visibility="gone" /> </RelativeLayout>5.给界面添加Fragmentpackage ...

    ImageView 实现Android colorPikcer 选择器的示例代码

    本文介绍了ImageView 实现Android colorPikcer 选择器的示例代码,分享给大家,具体如下: Android colorPikcer 选择器 环形的ColorPicker,主要思路是: Color 选在放在ImageView 的background上面,根据点击的...

    matlab加颜色代码-DailyProgress:一千英里始于一步

    background会放大,而src受scrollType影响。 状态栏 6.0+手机上沉浸式状态栏后若为白色背景 状态栏会出现灰框 可调整状态栏颜色为黑色 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){ getWindow()....

Global site tag (gtag.js) - Google Analytics