3

I am new in Android Application development, I want to create one application where I can add borders or frames to the images in the gallery. I have searched through some blogs but I didn't get the answer.

i want to create like this https://play.google.com/store/apps/details?id=com.tndev.loveframes&hl=en

Could anyone tell me the idea or any concept about how to do that application?

2 Answers2

8

Programmatically :

ImageView i = new ImageView(mContext);
Drawable d = null;
i.setImageDrawable(d);
        i.setAdjustViewBounds(true);
        i.setScaleType(ScaleType.CENTER_INSIDE);
        i.setBackgroundColor(Color.WHITE); //providing color to the background. 
        i.setPadding(3,3,3,3);//providing padding to the image.
        i.setLayoutParams(new Gallery.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

To overlay one image over another use Canvas class and check these links : Android: How to overlay-a-bitmap/draw-over a bitmap?

Community
  • 1
  • 1
Shail Adi
  • 1,502
  • 4
  • 14
  • 35
  • i need to create something like this https://play.google.com/store/apps/details?id=com.tndev.loveframes&hl=en –  Feb 18 '13 at 07:00
  • For that you should overlap your bitmap buy the frame bitmap you are using programmatically. One way is to use canvas. – Shail Adi Feb 18 '13 at 07:03
  • Check out these links : http://stackoverflow.com/questions/5433256/copy-one-bitmap-into-another-preserving-transparency http://stackoverflow.com/questions/1540272/android-how-to-overlay-a-bitmap-draw-over-a-bitmap – Shail Adi Feb 18 '13 at 07:04
  • I don't have any ready made code, but I think that the Canvas thing must work. Use your logic according to your requirement, as you understand it best. – Shail Adi Feb 18 '13 at 07:13
  • i need that overlay images will work..but i need to add list of frame and on click frames it will get the photo .. –  Feb 18 '13 at 07:55
  • For that keep the ids for frames and on select of the item of list view pass that id to use the bitmap of the frame. – Shail Adi Feb 18 '13 at 08:35
0

Method 1. If you want border you can put your imageView in a layout.

Then set a background color for the layout

Give padding for the layout so that the image and layout have space ( where the background color can be seen)

Method 2. You can use relative layout and place the image (first image view) over the border (2nd image view). For this the border should be of precise size.

Sample Layout :

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- Bottom layer -->
<ImageView 
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:src="bkgrnd"/>
<!-- Middle layer -->
<ImageView 
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:src="your_pic"/>
<!-- Top Layer -->
<ImageView 
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:src="ribbon_pic"/>

user2041902
  • 593
  • 1
  • 6
  • 21
  • i need something like this link https://play.google.com/store/apps/details?id=com.tndev.loveframes&hl=en –  Feb 18 '13 at 06:58
  • I have edited the answer. Please look into the sample layout section – user2041902 Feb 18 '13 at 08:02
  • You can set the background image in first imageView, your pic in the second one and the ribbon image which comes on top of your image as in the last image view. You can then use margin property to move images a bit left and right to get the approx placement. – user2041902 Feb 18 '13 at 08:12
  • You will also have to get the size of image and programmatically scale the ribbon to fit accordingly. – user2041902 Feb 18 '13 at 08:13