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

来源:互联网 发布:网络推广兼职是真是假 编辑:程序博客网 时间:2024/06/05 11:36

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

[java] view plain copy
  1. public ImageView imgDetail;  
  2. private RelativeLayout rlMain;  
  3.   
  4. rlMain= (RelativeLayout) findViewById(R.id.rlMain);//布局  
  5. imgDetail = (ImageView)findViewById(R.id.imgDetail); // 图片  
  6. //设置背景  
  7. rlMain.setBackgroundColor(Color.TRANSPARENT);  
  8. imgDetail.setBackgroundColor(Color.TRANSPARENT);  



主要用到类 : 

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

拓展:

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

0 0
原创粉丝点击