---
title: "android里设置图片透明。"
author: "flyering"
date: "2012-07-05T17:26:06Z"
tags: []
categories: ["移动开发"]
slug: "android"
draft: false
lastmod: "2012-07-05T17:26:06Z"
id: 1578031
url: "https://flyering.iteye.com/blog/1578031"
---

设置两张图片。 

        <ImageView
         android:id="@+id/imageView1"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         <span style="color:red">android:background</span>="@drawable/loadpage" />
        <ImageView
         android:id="@+id/imageView2"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:background="@drawable/default_image" />
注意，是android：background 。
然后是代码里控制。
im.getBackground().<span style="color:red">setAlpha(50);</span>此为，设置的透明度。