Bitmap XML和BitmapDrawable应用实例
来源:互联网 发布:sniffer捕获别人的数据 编辑:程序博客网 时间:2024/05/29 03:10
bitmap_xml.xml
<?xml version="1.0" encoding="utf-8"?><bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:dither="true" android:src="@drawable/beauty1" android:tileMode="disabled" ></bitmap>activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:background="@drawable/bitmap_xml" ></RelativeLayout>
MainActivity.java
package com.sean.bitmapxml;import android.app.Activity;import android.os.Bundle;public class MainActivity extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);}}
这里值得注意的有应用性的是android:tileMode这一属性。它的四个值效果图如下:
repeatmirrorclampdisabled
再来解释下android:dither的作用——图像的抖动处理,当每个颜色值以低于8位表示时,对应图像做抖动处理可以实现在可显示颜色总数比较低(比如256色)时还保持较好的显示效果。
以上是用bitmap XML应用bitmap资源,下面演示了代码实现,则要应用到BitmapDrawable:
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.beauty1);BitmapDrawable bd = new BitmapDrawable(bitmap);bd.setTileModeXY(TileMode.REPEAT, TileMode.REPEAT);bd.setDither(true);view.setBackgroundDrawable(bd);
- Bitmap XML和BitmapDrawable应用实例
- BitmapDrawable和Bitmap.XML的使用
- BitmapDrawable和Bitmap 详解和 BitmapDrawable和Bitmap
- 关于bitmap和bitmapdrawable之间的转换
- Android Bitmap 和 BitmapDrawable的区别
- 详解Bitmap使用,以及BitmapDrawable和BitmapFactory
- Bitmap , BitmapDrawable ,Drawable,byte[]
- Bitmap , BitmapDrawable ,Drawable,byte[]
- Bitmap,BitmapDrawable,BitmapFactory用法
- BitmapDrawable 与 Bitmap
- Android Drawable Resource学习(二)、BitmapDrawable和Bitmap
- Android Drawable Resource学习(二)、BitmapDrawable和Bitmap
- Android Drawable Resource学习(二)、BitmapDrawable和Bitmap
- Android Bitmap.setDensity(int density) 和 BitmapDrawable.setTargetDensity()
- Android Drawable Resource学习(二)、BitmapDrawable和Bitmap
- Android Drawable Resource学习(二)、BitmapDrawable和Bitmap
- Android Drawable Resource学习(二)、BitmapDrawable和Bitmap
- Android Drawable Resource学习(二)、BitmapDrawable和Bitmap
- linux中select()函数分析 (我已读过,并进行了微改动)
- 函数指针和指针函数
- sandbox paypal
- 阿里巴巴2013实习生笔试题精选2道算法题
- android系统信息(内存、cpu、sd卡、电量、版本)获取
- Bitmap XML和BitmapDrawable应用实例
- UIButton上使用UIEdgeInsetsMaketitle跟图片对齐
- 固定不更新界面的截屏
- vc6.0中选择打开文件命令时停止工作解决方法
- HTTP协议详解
- Good Websites Collection(WIP)
- js识别浏览器 选择CSS
- SAP--集团、公司、公司代码、工厂
- Flex 组件的定位和布局