Answer the question
In order to leave comments, you need to log in
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;
}
Answer the question
In order to leave comments, you need to log in
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));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question