Insert image in settings

I would like to do this in my android chat

enter image description here

but I can’t get my photo matching my bubble. -I have LinearLayout, and its background is a 9patch bubble -in this, I have an image, insert the image here , but not how to make it a suitable background, as we see on the screen.

that's how my image

enter image description here

can give me an idea of ​​how i can do this?

thank you.

UPDATE: 04/28/2013

this is my layout

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/rtlImganen" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="25dp" android:gravity="center_vertical" > <LinearLayout android:id="@+id/lnyGenImagenMio" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_centerVertical="true" android:background="@drawable/bocadilloazulmio" android:gravity="right" android:orientation="vertical" > <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" > <ImageView android:id="@+id/imgImagenMio" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:adjustViewBounds="true" android:maxHeight="@dimen/maximagen" android:maxWidth="@dimen/maximagen" android:scaleType="centerCrop" /> <ImageView android:id="@+id/imgPlayMio" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:src="@drawable/play" /> </RelativeLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="5dp" > <ImageView android:id="@+id/imgImagenEnvioRecibidoMio" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom" android:src="@drawable/enviadorecibido" /> <TextView android:id="@+id/txtFechaImagenVideoMio" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:textColor="#0000FF" android:textSize="8sp" /> </LinearLayout> </LinearLayout> </RelativeLayout> 

but I still haven't found a solution

+4
source share
1 answer

this can only be done with a custom view. I have the same problem. Take a look at Custom ImageView and Paths and crop the bitmap images. I wrote this snippet to cut out the shape of a speech bubble from a given bitmap:

  public static Bitmap clipit(Bitmap bitmapimg,int direct) { //1 = direction right //0 = direction left Bitmap output = Bitmap.createBitmap(bitmapimg.getWidth(), bitmapimg.getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(output); final int color = 0xff424242; final Paint paint = new Paint(); final Rect rect = new Rect(0, 0, bitmapimg.getWidth(), bitmapimg.getHeight()); paint.setAntiAlias(true); canvas.drawARGB(0, 0, 0, 0); paint.setColor(color); if(direct == 0) { canvas.drawRect(0, 0, bitmapimg.getWidth()-15, bitmapimg.getHeight(), paint); Path path = new Path(); path.moveTo(bitmapimg.getWidth()-15, 10); path.lineTo(bitmapimg.getWidth(), 20); path.lineTo(bitmapimg.getWidth()-15, 30); path.lineTo(bitmapimg.getWidth()-15, 10); canvas.drawPath(path,paint); } if(direct == 1) { canvas.drawRect(15, 0, bitmapimg.getWidth(), bitmapimg.getHeight(), paint); Path path = new Path(); path.moveTo(15, 10); path.lineTo(0, 20); path.lineTo(15, 30); path.lineTo(15, 10); canvas.drawPath(path,paint); } paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN)); canvas.drawBitmap(bitmapimg, rect, rect, paint); return output; } 

Does this solve your problem?

+3
source

All Articles