I'm creating a FrameLayout and then I add two Views (an ImageView and a TextView ).
My code on getView() :
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView;
TextView textView1;
int new_width = wid/2;
int textview_id=0;
FrameLayout frame_layout = new FrameLayout(mContext); // Instantiate the parent
frame_layout.setLayoutParams(new GridView.LayoutParams(android.widget.FrameLayout.LayoutParams.MATCH_PARENT,
android.widget.FrameLayout.LayoutParams.MATCH_PARENT));
textView1 = new TextView(mContext); textView1.setId(position);
textView1.setText("Set Wallpaper");
textView1.setTextColor(mContext.getResources().getColor(R.color.set_wallpaper_colors));
textView1.setVisibility(View.INVISIBLE);
textView1.setTypeface(textView1.getTypeface(), Typeface.BOLD);
FrameLayout.LayoutParams textview_params = new FrameLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
textview_params.gravity = Gravity.CENTER;
FrameLayout.LayoutParams imageview_params = new FrameLayout.LayoutParams(
new_width -5, new_width -5 );
imageView = new ImageView(mContext);
//imageView.setLayoutParams(new GridView.LayoutParams(new_width - 5, new_width -5));
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(0, 0, 0, 0);
imageView.setImageResource(mThumbIds[position]);
frame_layout.addView(imageView, imageview_params);
frame_layout.addView(textView1, textview_params);
return frame_layout;
}
How should I change it to use the ViewHolder class. There isn't a layout to inflate.
With your code it should be something like this
static class ViewHolder {
TextView textView1;
ImageView imageView1;
}
#Override
public View getView(final int row, View convertView, final ViewGroup parent) {
ViewHolder holder = null;
FrameLayout frame_layout = (FrameLayout) convertView;
if (frame_layout == null) {
holder = new ViewHolder();
holder.textView1 = new TextView(mContext);
holder.imageView1 = new ImageView(mContext);
frame_layout.setTag(holder);
}
else {
holder = (ViewHolder) frame_layout.getTag();
}
holder.textView1.setText("Set Wallpaper");
holder.textView1.setTextColor(mContext.getResources().getColor(R.color.set_wallpaper_colors));
holder.textView1.setVisibility(View.INVISIBLE);
holder.textView1.setTypeface(holder.textView1.getTypeface(), Typeface.BOLD);
FrameLayout.LayoutParams textview_params = new FrameLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
textview_params.gravity = Gravity.CENTER;
FrameLayout.LayoutParams imageview_params = new FrameLayout.LayoutParams(
new_width -5, new_width -5 );
holder.imageView1.setScaleType(ImageView.ScaleType.CENTER_CROP);
holder.imageView1.setPadding(0, 0, 0, 0);
holder.imageView1.setImageResource(mThumbIds[position]);
frame_layout.addView(holder.imageView1, imageview_params);
frame_layout.addView(holder.textView1, textview_params);
return frame_layout;
}
Related
What is have is custom grid view like this image :
And as you can see i have change the background color for the first five cell to green , but the thing is the other rows i want the first one to be white and the second grey , the third white the forth grey and so on ..
Here is my custom adapter code :
public class CustomGridAdapter extends BaseAdapter {
private Context context;
private ArrayList<String> itemsnew;
LayoutInflater inflater;
int value;
public CustomGridAdapter(Context context, ArrayList<String> itemsNew) {
this.context = context;
this.itemsnew = itemsNew;
inflater = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = inflater.inflate(R.layout.cell, null);
// if () {
// convertView = inflater.inflate(R.layout.cell2, null);
// EditText text2 = (EditText) convertView.findViewById(R.id.editText1);
//
//
// }
// else{
}
else if(position <5)
{
convertView = inflater.inflate(R.layout.cell, null);
TextView text = (TextView) convertView.findViewById(R.id.grid_item);
text.setTextColor(Color.parseColor("#703635"));
text.setPadding(5, 0, 5, 0);
LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
//llp.setMargins(5, 5, 5, 5); // llp.setMargins(left, top, right, bottom);
//llp.gravity=Gravity.RIGHT;
text.setBackgroundResource(R.drawable.back3);
text.setLayoutParams(llp);
// text.setGravity(Gravity.RIGHT);
text.setText(itemsnew.get(position));
}
else{
convertView = inflater.inflate(R.layout.cell, null);
TextView text = (TextView) convertView.findViewById(R.id.grid_item);
text.setTextColor(Color.BLACK);
text.setPadding(5, 0, 5, 0);
LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
//llp.setMargins(5, 5, 5, 5); // llp.setMargins(left, top, right, bottom);
//llp.gravity=Gravity.RIGHT;
text.setBackgroundResource(R.drawable.back2);
text.setLayoutParams(llp);
// text.setGravity(Gravity.RIGHT);
text.setText(itemsnew.get(position));
}
// }
// }
return convertView;
}
#Override
public int getCount() {
return itemsnew.size();
}
#Override
public Object getItem(int position) {
return itemsnew.get(position);
}
#Override
public long getItemId(int position) {
return position;
}
}
So how can i do this? any help?
Note : odd and even wont work because the white row will contain 5,6,7,8,9 position , and the grey one will be 10,11,12,13,14 ..
You could do exactly what you doing except using a little bit more math logic such as:
else if(position <5)
{
convertView = inflater.inflate(R.layout.cell, null);
TextView text = (TextView) convertView.findViewById(R.id.grid_item);
text.setTextColor(Color.parseColor("#703635"));
text.setPadding(5, 0, 5, 0);
LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
//llp.setMargins(5, 5, 5, 5); // llp.setMargins(left, top, right, bottom);
//llp.gravity=Gravity.RIGHT;
text.setBackgroundResource(R.drawable.back3);
text.setLayoutParams(llp);
// text.setGravity(Gravity.RIGHT);
text.setText(itemsnew.get(position));
}
else
{
convertView = inflater.inflate(R.layout.cell, null);
TextView text = (TextView) convertView.findViewById(R.id.grid_item);
text.setTextColor(Color.BLACK);
text.setPadding(5, 0, 5, 0);
LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
//llp.setMargins(5, 5, 5, 5); // llp.setMargins(left, top, right, bottom);
//llp.gravity=Gravity.RIGHT;
if((position/5)%2 < 1){
text.setBackgroundResource(R.drawable.back2); <<<<<<SET TO WHITE
}else{
text.setBackgroundResource(R.drawable.back4); <<<<<<SET TO GREY
}
text.setLayoutParams(llp);
// text.setGravity(Gravity.RIGHT);
text.setText(itemsnew.get(position));
}
Since your table is being set 5 positions at a time this will check by row. Also you will probably need to change the position variable into a float or long, not in the method but can do something like
float pos = position*1.0f
Try it and let me know.
i try to make my image view position dynamic base on image height. but i stuck to get the image height from drawable.. help me to solve it thanks..
this is my code :
#Override
public View getView(int position, View view, ViewGroup parent) {
LayoutInflater inflater = context.getLayoutInflater();
View rowView= inflater.inflate(R.layout.list_wall, null, true);
TextView txtProfileUser = (TextView) rowView.findViewById(R.id.txtWallProfile);
TextView txtTitle = (TextView) rowView.findViewById(R.id.txtWallContentTitle);
TextView txtContent = (TextView) rowView.findViewById(R.id.txtWallContent);
ImageView imgWallProfile = (ImageView) rowView.findViewById(R.id.ivWallProfile);
ImageView imgWallContent = (ImageView) rowView.findViewById(R.id.ivWallContent);
txtTitle.setText(web2[position]);
txtContent.setText(web3[position]);
txtProfileUser.setText(web[position]);
imgWallProfile.setImageResource(imageId[position]);
imgWallContent.setImageResource(imageId2[position]);
GetSize gz = new GetSize();
Integer h = gz.getImageSize(imageId[position]);
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
lp.setMargins(20,h, 0, 0);
imgWallProfile.setLayoutParams(lp);
return rowView;
}
and this my getImageSize method :
public Integer getImageSize(Integer d){
Drawable bd = getResources().getDrawable(d);
int height=bd.getIntrinsicHeight();
return height;}
If I understand correctly you want to get the width and height of your image view instead of the bitmaps width and height. Layout parameters allows you to access the imageView and view and modify it's parameters.
public int getImageSize(View myView) {
RelativeLayout.LayoutParams myParams = (RelativeLayout.LayoutParams) myView.getLayoutParams();
return myParams.height;
}
At first i have a method to create view(yes i know its wrong, but it works fine for me):
public ImageView createPhotoField(final Context context,
LinearLayout reviewsLayout, Integer id, String comment, OnClickListener a, OnClickListener b, int tag) {
/* reviewLayout */
LinearLayout reviewLayout = new LinearLayout(context);
reviewLayout.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT, densityToPixels(132,
context)));
reviewLayout.setOrientation(LinearLayout.VERTICAL);
reviewLayout.setGravity(Gravity.CENTER_VERTICAL);
/* reviewEntryTopLayout */
LinearLayout reviewEntryTopLayout = new LinearLayout(context);
reviewEntryTopLayout.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT, densityToPixels(65,
context)));
reviewEntryTopLayout.setOrientation(LinearLayout.HORIZONTAL);
reviewEntryTopLayout.setGravity(Gravity.CENTER_VERTICAL);
/* reviewsLayout */
reviewsLayout.addView(reviewLayout);
/* entryNumber */
ImageView imageview = new ImageView(context);
LinearLayout.LayoutParams entryNumberParams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
imageview.setTag(tag);
entryNumberParams.setMargins(40, 0, 0, 0);
imageview.setLayoutParams(entryNumberParams);
imageview.setBackgroundResource(R.drawable.ic_bad);
imageview.setImageResource(R.drawable.ic_bad);
//entryNumber.set
imageview.setVisibility(View.GONE);
reviewLayout.addView(reviewEntryTopLayout);
//reviewEntryTopLayout.addView(entryNumber);
/* table layout */
TableLayout tl = new TableLayout(context);
tl.setLayoutParams(new TableLayout.LayoutParams(
TableLayout.LayoutParams.MATCH_PARENT,
TableLayout.LayoutParams.WRAP_CONTENT, 1.0f));
tl.setPadding(densityToPixels(20, context), 0, 0, 0);
reviewEntryTopLayout.addView(tl);
/* tableRow1 */
TableRow tableRow1 = new TableRow(context);
tableRow1.setLayoutParams(new TableRow.LayoutParams(
TableRow.LayoutParams.WRAP_CONTENT,
TableRow.LayoutParams.WRAP_CONTENT));
tl.addView(tableRow1);
/* textView1 */
TextView comment_photo = new TextView(context);
comment_photo.setLayoutParams(new TableRow.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
comment_photo.setText(comment);
tableRow1.addView(imageview);
tableRow1.addView(comment_photo);
/* lightSeperatorLayout */
LinearLayout lightSeperatorLayout = new LinearLayout(context);
lightSeperatorLayout.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT, densityToPixels(1,
context)));
lightSeperatorLayout.setOrientation(LinearLayout.VERTICAL);
lightSeperatorLayout.setBackgroundColor(Color.parseColor("#d5d5d5"));
/* reviewEntryBottomLayout */
LinearLayout reviewEntryBottomLayout = new LinearLayout(context);
reviewEntryBottomLayout.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT, densityToPixels(65,
context)));
reviewEntryBottomLayout.setOrientation(LinearLayout.VERTICAL);
reviewEntryBottomLayout.setGravity(Gravity.CENTER_VERTICAL);
reviewLayout.addView(reviewEntryBottomLayout);
/* tableRow3 */
TableRow tableRow3 = new TableRow(context);
tableRow3.setLayoutParams(new TableRow.LayoutParams(
TableRow.LayoutParams.FILL_PARENT,
TableRow.LayoutParams.WRAP_CONTENT));
tableRow3.setPadding(densityToPixels(10, context),
densityToPixels(10, context), densityToPixels(10, context),
densityToPixels(10, context));
reviewEntryBottomLayout.addView(tableRow3);
/* editButton */
Button editButton = new Button(context);
TableRow.LayoutParams editButtonParams = new TableRow.LayoutParams(
Tabl
eRow.LayoutParams.WRAP_CONTENT, 150);
editButtonParams.weight = 0.5f;
editButtonParams.setMargins(15, 0, 30, 0);
editButton.setLayoutParams(editButtonParams);
editButton.setText("Take a photo");
tableRow3.addView(editButton);
/* reviewButton */
Button reviewButton = new Button(context);
TableRow.LayoutParams reviewButtonParams = new TableRow.LayoutParams(
TableRow.LayoutParams.WRAP_CONTENT, 150);
reviewButtonParams.weight = 0.5f;
reviewButtonParams.setMargins(30, 0, 15, 0);
reviewButton.setLayoutParams(reviewButtonParams);
reviewButton.setText("Gallery");
tableRow3.addView(reviewButto
n);
reviewLayout.addView(lightSeperatorLayout);
editButton.setOnClickListener(a);
reviewButton.setOnClickListener(b);
return imageview;
}
long story short: this method creates: an imageview, for a photo, a text field, and two buttons, to choose u take a photo, or u take it from gallery.
After calling this method below few times the view is created
image = element.createPhotoField(this, reviewsLayout,
Integer.parseInt(element_id), input_name, a, b,tag);
the problem is: i can't find a way to place a photo in a right place. I have heard about tags, but i dont know how to implement those. Could somebody more experienced give me a hand ?
Maybe i should use adapter for this ??
Use something like this in your adapter is required to achieve what you need :
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View view=convertView;
ViewHolder holder;
if(convertView==null){
view = inflater.inflate(R.layout.youListItem, null);
holder = new ViewHolder();
holder.image=(ImageView)view.findViewById(R.id.youImageView);
view.setTag(holder);
}
else
holder=(ViewHolder)view.getTag();
holder.image.setTag(data[position]);
//to display image
holder.image.setImageDrawable(YourImageDrawable);
return view;
}
public static class ViewHolder{
//view elements of single list item
public ImageView image;
}
I have a RelativeLayout with 4 ImageViews that should have 2 on top, one on each side of the Layout, and 2 ImageViews below the first two, one on each side of the screen.
I have 2 problems, the two ImageViews that are supposed to be below, do not go below. And The 2 ImageViews that are aligned to be on the right of the screen should be one on top of the other but seem to be about 25dp out.
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState){
View v = inflater.inflate(R.layout.fragment_hello_moon, parent, false);
RelativeLayout tl = (RelativeLayout)v.findViewById(R.id.l1);
tl.setBackgroundColor(Color.WHITE);
ImageView imageTopL = new ImageView(getActivity());
imageTopL.setImageResource(R.drawable.bell_dl_256);
imageTopL.setPadding(50, 0, 0, 0);
imageTopL.setId(0);
ImageView imageBottomL = new ImageView(getActivity());
imageBottomL.setImageResource(R.drawable.bell_dl_256);
imageBottomL.setPadding(50, 0, 0, 0);
imageBottomL.setId(1);
ImageView imageBottomR = new ImageView(getActivity());
imageBottomR.setImageResource(R.drawable.bell_dr_256);
imageBottomR.setPadding(0, 0, 50, 0);
imageBottomR.setId(2);
ImageView imageTopR = new ImageView(getActivity());
imageTopR.setImageResource(R.drawable.bell_dr_256);
imageTopR.setPadding(0, 0, 50, 0);
imageTopR.setId(3);
tl.addView(imageTopL);
tl.addView(imageTopR);
tl.addView(imageBottomL);
tl.addView(imageBottomR);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)imageTopL.getLayoutParams();
params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
params = (RelativeLayout.LayoutParams)imageTopR.getLayoutParams();
params.addRule(RelativeLayout.RIGHT_OF, imageTopL.getId());
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
params = (RelativeLayout.LayoutParams)imageBottomL.getLayoutParams();
params.addRule(RelativeLayout.BELOW, imageTopL.getId());
params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
params = (RelativeLayout.LayoutParams)imageBottomR.getLayoutParams();
params.addRule(RelativeLayout.BELOW, imageTopL.getId());
params.addRule(RelativeLayout.RIGHT_OF, imageBottomL.getId());
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
return v;
// try this
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState){
View v = inflater.inflate(R.layout.fragment_hello_moon, parent, false);
RelativeLayout tl = (RelativeLayout) v.findViewById(R.id.l1);
tl.setBackgroundColor(Color.WHITE);
ImageView imageTopL = new ImageView(this);
imageTopL.setId(1);
imageTopL.setImageResource(R.drawable.ic_launcher);
RelativeLayout.LayoutParams params1 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
imageTopL.setAdjustViewBounds(true);
params1.addRule(RelativeLayout.ALIGN_PARENT_TOP);
params1.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
params1.setMargins(50,10,0,0);
imageTopL.setLayoutParams(params1);
imageTopL.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Toast.makeText(ImageTextListViewActivity.this,"Top Left",Toast.LENGTH_SHORT).show();
}
});
ImageView imageTopR = new ImageView(this);
imageTopR.setId(2);
imageTopR.setImageResource(R.drawable.ic_launcher);
imageTopL.setAdjustViewBounds(true);
RelativeLayout.LayoutParams params2 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
params1.addRule(RelativeLayout.ALIGN_PARENT_TOP);
params2.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
params2.setMargins(0,10,50,0);
imageTopR.setLayoutParams(params2);
imageTopR.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Toast.makeText(ImageTextListViewActivity.this,"Top Right",Toast.LENGTH_SHORT).show();
}
});
ImageView imageBottomL = new ImageView(this);
imageBottomL.setId(3);
imageBottomL.setImageResource(R.drawable.ic_launcher);
imageTopL.setAdjustViewBounds(true);
RelativeLayout.LayoutParams params3 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
params3.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
params3.addRule(RelativeLayout.BELOW, imageTopL.getId());
params3.setMargins(50,10,0,0);
imageBottomL.setLayoutParams(params3);
imageBottomL.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Toast.makeText(ImageTextListViewActivity.this,"Bottom Left",Toast.LENGTH_SHORT).show();
}
});
ImageView imageBottomR = new ImageView(this);
imageBottomR.setId(4);
imageBottomR.setImageResource(R.drawable.ic_launcher);
imageTopL.setAdjustViewBounds(true);
RelativeLayout.LayoutParams params4 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
params4.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
params4.addRule(RelativeLayout.BELOW, imageTopR.getId());
params4.setMargins(0,10,50,0);
imageBottomR.setLayoutParams(params4);
imageBottomR.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Toast.makeText(ImageTextListViewActivity.this,"Bottom Right",Toast.LENGTH_SHORT).show();
}
});
tl.addView(imageTopL);
tl.addView(imageTopR);
tl.addView(imageBottomL);
tl.addView(imageBottomR);
return v;
}
I'm trying to surround the top and bottom of my ImageView in a Gallery with a layout containing a tiled background. The top part seems to be working, but the bottom layout doesn't show. Any ideas why? Here's my getView():
public View getView(int position, View convertView, ViewGroup parent) {
RelativeLayout container = new RelativeLayout(galleryContext);
RelativeLayout topReel = new RelativeLayout(galleryContext);
RelativeLayout bottomReel = new RelativeLayout(galleryContext);
topReel.setBackgroundResource(R.drawable.film_top);
bottomReel.setBackgroundResource(R.drawable.film_bottom);
ImageView imageView = null;
if (convertView != null) { //we can reuse the view!
imageView = (ImageView) convertView;
} else {
imageView = new ImageView(galleryContext); //boo we have to make a new view
}
//Get a scaled Bitmap so that it doesn't use up all our memory
Bitmap setBitmap = loadScaledBitmap(imageList[position].getAbsolutePath(), imageSizeInPixels);
//set up our ImageView inside the gallery to display our Bitmap...
imageView.setImageBitmap(setBitmap);
imageView.setLayoutParams(new Gallery.LayoutParams(imageSizeInPixels, imageSizeInPixels));
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
imageView.setBackgroundResource(galleryBackground);
RelativeLayout.LayoutParams topParams = new RelativeLayout.LayoutParams(imageSizeInPixels, 20);
topParams.addRule(RelativeLayout.ABOVE, imageView.getId());
topParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
RelativeLayout.LayoutParams bottomParams = new RelativeLayout.LayoutParams(imageSizeInPixels, 20);
bottomParams.addRule(RelativeLayout.BELOW, imageView.getId());
bottomParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
RelativeLayout.LayoutParams imageParams = new RelativeLayout.LayoutParams(imageSizeInPixels, imageSizeInPixels);
imageParams.addRule(RelativeLayout.BELOW, topReel.getId());
imageParams.addRule(RelativeLayout.ABOVE, bottomReel.getId());
imageParams.addRule(RelativeLayout.CENTER_VERTICAL);
imageParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
container.addView(topReel, topParams);
container.addView(bottomReel, bottomParams);
container.addView(imageView, imageParams);
return container;
}
This solves the problem, hopefully someone can use this:
public View getView(int position, View convertView, ViewGroup parent) {
RelativeLayout container = new RelativeLayout(galleryContext);
ImageView imageView = null;
if (convertView != null) { //we can reuse the view!
imageView = (ImageView) convertView;
} else {
imageView = new ImageView(galleryContext); //boo we have to make a new view
}
//Get a scaled Bitmap so that it doesn't use up all our memory
Bitmap setBitmap = loadScaledBitmap(imageList[position].getAbsolutePath(), ((int)(imageSizeInPixels * .75)));
//set up our ImageView inside the gallery to display our Bitmap...
imageView.setImageBitmap(setBitmap);
imageView.setLayoutParams(new Gallery.LayoutParams(imageSizeInPixels, imageSizeInPixels));
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
imageView.setBackgroundColor(Color.BLACK);
RelativeLayout borderImg = new RelativeLayout(galleryContext);
borderImg.setPadding(10, 5,10, 5);
borderImg.setBackgroundColor(0xff000000);
borderImg.addView(imageView);
RelativeLayout.LayoutParams imageParams = new RelativeLayout.LayoutParams(imageSizeInPixels, imageSizeInPixels);
imageParams.addRule(RelativeLayout.CENTER_VERTICAL);
imageParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
container.setBackgroundResource(R.drawable.repeat_reel);
container.setLayoutParams(new Gallery.LayoutParams(imageSizeInPixels, imageSizeInPixels+40));
container.addView(borderImg, imageParams);
return container;
}