2012-10-12 72 views

回答

1

尝试这样:

Bitmap someImage; 


int width = someImage.getWidth(); 
int height = someImage.getHeight(); 

RectF targetRect = new RectF(3, 3, width - 3, height - 3); 

Bitmap dest = Bitmap.createBitmap(width + 20, height + 20,someImage.getConfig()); 

Canvas canvas = new Canvas(dest); 
canvas.drawColor(Color.RED); 
canvas.drawBitmap(someImage, null, targetRect, null); 

根据您的需要只要改变填充和颜色。

希望有帮助! :)

0

可以使用

android:background="path"到图像帧应该只有框架边框 和中心部分应该是透明的,

你的形象应该被指定为

androd:src="path" ....

并且还给填充 即

android:padding="3dp" 填充可能高达5DP或者它应该取决于你的框架边框的厚度......

所以它看起来像......

enter image description here

 <ImageView 
      android:id="@+id/activity_test_img_signs" 
      android:layout_width="@dimen/imagesize" 
      android:layout_height="@dimen/imagesize" 
      android:background="@drawable/img_border_new" 
      android:contentDescription="@string/app_name" 
      android:padding="@dimen/padding_small" 
      android:scaleType="fitXY" 
      android:src="@drawable/q101" 
      android:visibility="invisible" /> 
1
  1. 在可绘制文件夹中为此形状创建一个XML get code from here

  2. 将此形状设置为相对布局。

  3. 创建一个相对布局一个图像视图,并在系统运行时设定一个图片src:

    ImageView imageViewMyGraphicalImageElement= (ImageView) findViewById(R.id.imageViewMyGraphicalImageElement); 
    
    imageViewMyGraphicalImageElement.setImageBitmap(sBitmap); 
    
+0

队友....谢谢SOOOO多的这种宝石埋藏的所有建议之间...我尝试了几乎所有的东西,没有为我的情况工作,除了这:)我浪费了3个小时试图实现有我的imageview边界,直到找到这个职位 – Abolfoooud