2014-01-15 27 views
1

我正在研究Android上的照片拼贴项目。我想知道如何实现以下拼贴效果?如何在Android上实现照片拼贴

enter image description here

因此,有两张照片将适用于每一个三角形。

或更复杂的形状是这样的:(这将HOD 5张) enter image description here

+0

您是否找到了解决方案? –

回答

4

这并不那么容易。

一个解决办法是从this thread(关右上角削减)删除您的图像,如下面的代码片段中不需要的像素:

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 

    ImageView iv = (ImageView) findViewById(R.id.your_image); 
    int drawableId = R.drawable.your_drawable; 
    cutOffTopRightCorner(iv, drawableId, skewWidth); 
} 

@SuppressLint("NewApi") 
private void cutOffTopRightCorner(ImageView iv, int resId, int skewWidth) { 
    Bitmap bm = BitmapFactory.decodeResource(getResources(), resId).copy(Config.ARGB_8888, true); 
    bm.setHasAlpha(true); 
    final int bmWidth = bm.getWidth(); 

    for (int i = bmWidth; i > bmWidth - skewWidth; --i) { 
     for (int k = 0; k < i - (bmWidth - skewWidth); ++k) { 
      bm.setPixel(i - 1, k, Color.TRANSPARENT); 
     } 
    } 
    iv.setImageBitmap(bm); 
} 

另一个解决方案是与FrameLayouts工作(differenz Z-索引),并用其他图像或绘图覆盖图像。

您还可以看看this thread.

+0

但这并不能解决照片叠加问题。 – John