W
W
web_dev2013-09-03 22:10:41
Android
web_dev, 2013-09-03 22:10:41

View border and changeable view color?

Hello, I’ve “googled”, but I can’t find a clear solution, maybe the society will tell you ...
The essence of the problem.
There is a ListView, in the adapter I give view.
Each item has its own color, which is selected by the user using the "color picker". There are no problems with this, but I also want a frame for all this ...
and that's the trouble it turns out, it turns out either a frame or a color, the commands overlap each other ...

@Override
  public View getView(int position, View convertView, ViewGroup parent) {

.....
//рисую с хмл в котором у меня прописано только свойство "stroke" 
// во второй строчке устанавливаю цвет который выбрал пользователь.
//если строчки поменять, то получу рамку, а цвета не получу.
    convertView.setBackground(context.getResources().getDrawable(R.drawable.period_row_style));
    convertView.setBackgroundColor(periods.get(position).getColor());

.....
        		return convertView;
  }

The question is, how do I get both the border and the color in an item?
Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
bimeg, 2013-09-04
@web_dev

To combine two Drawables you can use LayerDrawable for example.

Drawable[] d = new Drawable[] { new ColorDrawable(periods.get(position).getColor()), context.getResources().getDrawable(R.drawable.period_row_style)};
convrtView.setBackground(new LayerDrawable(d));

Something like this.

W
web_dev, 2013-09-05
@web_dev

))) Finally, I'm not finished myself, although everything is logical, you need to put a transparent background in the shape.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question