0

I'm not really sure if it's the thickness of the border or the margin around the image that needs to be changed. I have never worked with styles before, and just created a styles.xml and colors.xml file for the first time. I have changed the background color to Red, using the code below in image_border.xml. But I do not know how to change the border thickness around the images in HelloGallery.

Perhaps it's not in this file. But what exactly needs to be written in the code?

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:top="1dp" android:left="1dp" 
        android:right="1dp" android:bottom="1dp">
        <shape android:shape="rectangle">
            <solid android:color="@color/red" />
        </shape>
    </item>
</layer-list>

Edit: The answer might actually be a matter of modifying this portion of the code, since I was able to change the border color and image size here:

    public View getView(int position, View convertView,
      ViewGroup parent) {
        ImageView i = new ImageView(mContext);

        Bitmap bm = BitmapFactory.decodeFile(
        FileList.get(position).toString());
        i.setImageBitmap(bm);
        i.setLayoutParams(new Gallery.LayoutParams(160, 180));
        i.setScaleType(ImageView.ScaleType.FIT_XY);
        i.setBackgroundResource(mGalleryItemBackground);
        i.setBackgroundColor(Color.BLUE);
        return i;
    }
Dave
  • 4,949
  • 6
  • 50
  • 73
  • you might want to check this: http://stackoverflow.com/a/1598200/862629 – Sam Felix Jan 27 '12 at 00:59
  • If the answer is in there, it is like a needle in a haystack to me, since this is literally the first time I have ever tried to adjust the border or even the color of anything in Java or Android. Is it the shape tag? I have no idea. – Dave Jan 27 '12 at 01:06

3 Answers3

0

You're almost there. A border is called a stroke, you can specify it like this:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:top="1dp" android:left="1dp" 
    android:right="1dp" android:bottom="1dp">
    <shape android:shape="rectangle">
        <solid android:color="@color/red" />
        <stroke android:width="1dp" />
    </shape>
</item>

frikkenator
  • 241
  • 1
  • 3
  • It appears that the HelloGallery example has a rectangle around the scrolling images, so the XML I posted above might be misleading. It is the images not the rectangle around them I need to change. The solution might be in a totally different part of the code. – Dave Jan 27 '12 at 01:26
0

I think a simple solution for you is here:

http://groups.google.com/group/android-developers/browse_thread/thread/157740b639959c47?pli=1

hope it helps

Sam Felix
  • 1,329
  • 1
  • 10
  • 23
  • It seems whatever I do to that XML segment I posted above effects just the rectangle around the scrolling images in the HelloGallery code. I was unaware whether the solution was in that segment of code or not, but it appears not. – Dave Jan 27 '12 at 01:28
0

The border around the image actually is background padding:

i.setPadding(1, 1, 1, 1);

Dave
  • 4,949
  • 6
  • 50
  • 73