码迷,mamicode.com
首页 > 移动开发 > 详细

Android 如何把一个 RelativeLayout或ImageView背景设为透明

时间:2015-04-17 19:51:15      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:

在项目中,需要把RelativeLayout 和  ImageView背景设置为透明,怎么实现呢?这里主要通过代码,请参阅以下关键代码:

public ImageView imgDetail;
private RelativeLayout rlMain;

rlMain= (RelativeLayout) findViewById(R.id.rlMain);//布局
imgDetail = (ImageView)findViewById(R.id.imgDetail); // 图片
//设置背景
rlMain.setBackgroundColor(Color.TRANSPARENT);
imgDetail.setBackgroundColor(Color.TRANSPARENT);

主要用到类 :

android.graphics.Color 和 android.view.View 类的setBackgroundColor方法!

拓展:

android中其他继承android.view.View 类,背景设置为透明的方法也类似!

Android 如何把一个 RelativeLayout或ImageView背景设为透明

标签:

原文地址:http://www.cnblogs.com/zhujiabin/p/4435476.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!