2015-09-06 161 views

回答

1

使用容器的FrameLayout。現在,將ImageView放入此FrameLayout並調整其alpha值。所以,你的佈局結構看起來就像這樣

FrameLayout (Container) 
|__ImageView1 (Background) 
|__ImageView2 (Text) 

對於模糊效果,你可以使用任何在互聯網上的Android圖像處理庫。

+0

要麼設置的幀佈局的背景爲第一圖像,或只加對於高度和寬度都使用匹配父級的imageview。我認爲將父框架佈局的背景設置爲您的第一個圖像更有意義 –

0

創建兩個圖像的位圖,並使用Canvas

ImageView image = (ImageView) findViewById(R.id.imageView1); 
      Drawable drawableFore = getResources().getDrawable(R.drawable.foreg); 
      Drawable drawableBack = getResources().getDrawable(R.drawable.backg); 

      Bitmap bitmapFore = ((BitmapDrawable) drawableFore).getBitmap(); 
      Bitmap bitmapBack = ((BitmapDrawable) drawableBack).getBitmap(); 

      Bitmap scaledBitmapFore = Bitmap.createScaledBitmap(bitmapFore, 35, 35, true); 
      Bitmap scaledBitmapBack = Bitmap.createScaledBitmap(bitmapBack, 45, 45, true); 

      Bitmap combineImages = overlay(scaledBitmapBack, scaledBitmapFore); 

      image.setImageBitmap(combineImages); 

覆蓋方法是在這裏mearge它..

public static Bitmap overlay(Bitmap bmp1, Bitmap bmp2) 
{ 
try 
{ 
    Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig()); 
    Canvas canvas = new Canvas(bmOverlay); 
    canvas.drawBitmap(bmp1, new Matrix(), null); 
    canvas.drawBitmap(bmp2, 0, 0, null); 
    return bmOverlay; 
} catch (Exception e) 
{ 
    // TODO: handle exception 
    e.printStackTrace(); 
    return null; 
} 
}