-1

This is not the same question as the two questions I posted before, same app but different question. I am adding ImageButtons one at a time to a GridLayout using RecyclerView. My app listens for incoming images and strings to label the buttons.

I need the background of the buttons to be transparent (not the grey square you see). If I set:

android:background="#00000000"

for my blank image button that gets filled using RecyclerView, then it is like a transparent button is placed on top of my image, and my onClickListener for my button doesn't work anymore. Where do I set these parameters? In my RecyclerViewAdapter?

  • Hi, but if the grey is the background of the actual image, then you should use a different program to set the background of the actual image to transparent. In any case, please try setting `holder.AppButton.setBackgroundResource(R.color.mytransparent);` where `R.color.mytransparent` is defined in your Styles.xml as `#00000000 `. Give it a try and let me know if this helps. – ishmaelMakitla May 16 '16 at 20:03
  • @ishmaelMakitla The grey is not the actual part of the image, it is something that is added to the images when its put into the button. But I'll try what you said thank you – Emily Di-Lee May 16 '16 at 20:34
  • OK, please give it try and let me know if it helps, otherwise we can explore other solutions. – ishmaelMakitla May 16 '16 at 20:45

1 Answers1

1

In your onBindViewHolder, you can try and set the color of the ImageButton (holder.AppButton) to transparent. Do something like this:

public void onBindViewHolder(RecyclerViewHolders holder, int position) {
 holder.AppName.setText(itemList.get(position).getName());
 holder.AppButton.setImageDrawable(itemList.get(position).getPhoto());
 //this is where you set the background to transparent...
 holder.AppButton.setBackgroundColor(Color.TRANSPARENT);
}

I hope this helps, please try it out and let me know if it does help.

ishmaelMakitla
  • 3,784
  • 3
  • 26
  • 32
  • Thank you so much it worked. I'm going to approve your answer. Also I posted a similar question here: (if you might be able to answer it :) ) thank you so much --- http://stackoverflow.com/questions/37259844/how-to-set-size-of-margins-in-gridlayout – Emily Di-Lee May 16 '16 at 22:00