I have the following shape drawable:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid
android:color="#000000"
/>
<size
android:width="100dp"
android:height="100dp"
/>
</shape>
</item>
</layer-list>
And it's called like this from my main layout:
<ImageView
android:id="@+id/circle_bg"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentLeft="true"
android:background="@drawable/circle_bg" />
I have an adapter that's used to populate the layout with other data, but one of these data is a hex color code. Here's an example of how I populate the layout's main content:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Post post = getItem(position);
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.post_layout, parent, false);
}
TextView content = (TextView) convertView.findViewById(R.id.content);
content.setText(article.getContent());
return convertView;
}
Which populates this part of the layout:
<TextView
android:id="@+id/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
/>
How can I, programmatically, do the same for the shape so that I can change its color?