Android findViewById in shape background returns null - android

I want to get Item in layer-list which is in xbutton.xml.
button.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:right="5dp" android:left="5dp" android:bottom="6dp" android:top="5dp">
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<stroke android:width="3dip" android:color="#FFF" />
<solid android:color="#003055"/>
<corners android:radius="22dp" />
</shape>
</item>
<item android:right="10dp" android:left="10dp" android:bottom="11dp" android:top="10dp">
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient
android:angle="90"
android:endColor="#0184c9"
android:startColor="#003055"
android:type="linear" />
<corners android:radius="19dp" />
</shape>
</item>
<item android:left="-30dp" android:top="20dp" android:id="#+id/itemIcon">
<bitmap android:src="#drawable/coin" android:gravity="center"></bitmap>
</item>
</layer-list>
main_activity.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/background_hdpi"
tools:context=".MainActivity">
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout"
android:layout_marginTop="25dp"
android:layout_marginLeft="35dp"
android:layout_marginRight="35dp"
android:orientation="horizontal">
<Button
android:id="#+id/list1button"
android:layout_width="match_parent"
android:layout_height="60dp"
android:textSize="16sp"
android:background="#drawable/xbutton"
android:drawablePadding="#dimen/activity_horizontal_margin"
android:gravity="left|center_vertical"
android:drawableLeft="#drawable/ikona1"
style="#style/ButtonShadowText"
android:onClick="onClickBtn"/>
</LinearLayout>
</RelativeLayout>
When I try to get item by
View itemCoin = findViewById(R.id.itemIcon);
I get null for itemCoin. I want to change the android:left value in item.
I can get other view i.e. list1button.

final LayerDrawable exampleDrawable = (LayerDrawable) getResources().getDrawable(R.drawable.example);
final ClipDrawable d1 = (ClipDrawable) exampleDrawable.findDrawableByLayerId(R.id.customitemIcon);
findDrawableByLayerId is for searching layers in drawable and findViewById is for VIEWS

Related

How to generate Circle Shape With Outer Ring

How to generate views as shown below,
I tried to adding stroke to cardView(Material cardView) and using it in a recyclerView. I have used multiple views, below is the xml code for the outer ring
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginStart="6dp"
android:layout_marginEnd="6dp"
android:gravity="center">
<com.google.android.material.circularreveal.cardview.CircularRevealCardView
android:id="#+id/selectedCardColor"
android:layout_width="40dp"
android:layout_height="40dp"
android:visibility="visible"
app:cardBackgroundColor="#color/app_color_white"
app:strokeColor="#color/app_color_green"
app:strokeWidth="1dp"
app:cardCornerRadius="28dp"
app:cardPreventCornerOverlap="true"
app:cardUseCompatPadding="false">
<com.google.android.material.circularreveal.cardview.CircularRevealCardView
android:id="#+id/selectedCardInnerColor"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center"
android:layout_margin="6dp"
app:cardBackgroundColor="#color/app_color_green"
app:cardCornerRadius="28dp"
app:cardPreventCornerOverlap="true"
app:cardUseCompatPadding="false" />
</com.google.android.material.circularreveal.cardview.CircularRevealCardView>
</LinearLayout>
and the code for circle shape,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/parent"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginStart="6dp"
android:layout_marginEnd="6dp">
<com.google.android.material.card.MaterialCardView
android:id="#+id/unSelectedCardColor"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_marginTop="3dp"
android:layout_marginBottom="3dp"
app:cardBackgroundColor="#color/app_color_green"
app:cardCornerRadius="28dp"
app:cardPreventCornerOverlap="true"
app:cardUseCompatPadding="false" />
</LinearLayout>
It works only in pie(android 9) and above. Other devices it appears as below,
The ring should appear on selected views. I should be able to change color programmatically. Thanks.
Try if it works .....Make a ring.xml in your Drawable folder
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:top="20dp" android:left="20dp" android:bottom="20dp" android:right="20dp" >
<shape >
<solid android:color= "#FF0000"/>
<corners android:radius="300dp"/>
</shape>
</item>
<item android:left="40dp" android:bottom="40dp" android:top="40dp" android:right="40dp" >
<shape >
<solid android:color= "#ffffff"/>
<corners android:radius="300dp"/>
</shape>
</item>
<item android:left="60dp" android:bottom="60dp" android:right="60dp" android:top="60dp" >
<shape >
<gradient
android:startColor="#00ffff"
android:endColor="#0000ff"
android:angle="90"/>
<corners android:radius="300dp"/>
<stroke android:width="1dp"/>
</shape>
</item>
</layer-list>
please replace the white color with the color of YOUR BACKGRAOUND
use it wherever you like.eg as the background of your button
You may change the color of the ring in the first item and change the color of circle shape in the last item.
Please Try Below code
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:top="5dp"
android:left="5dp"
android:bottom="5dp"
android:right="5dp" >
<shape >
<solid android:color= "#090909"/>
<corners android:radius="400dp"/>
</shape>
</item>
<item android:left="10dp"
android:bottom="10dp"
android:top="10dp"
android:right="10dp">
<shape >
<solid android:color= "#ffffff"/>
<corners android:radius="300dp"/>
</shape>
</item>
<item
android:left="20dp"
android:bottom="20dp"
android:right="20dp"
android:top="20dp" >
<shape
android:shape="oval">
<solid
android:color="#9C27B0"/>
<size
android:width="200dp"
android:height="200dp"/>
</shape>
</item>

Add foreground within borders

I have a recylcerview with borders, and i want to add an animation to the bordered area only, how do i add it? I want to add android:foreground="?attr/selectableItemBackground" such that when row is clicked, only the bordered area displays the animation, not the whole row
Recycler View
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/recycler_view" />
</androidx.constraintlayout.widget.ConstraintLayout>
Row item
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/pokedex_row"
android:padding="10sp"
android:clickable="true"
android:focusable="true"
android:background="#drawable/card_background"
android:elevation="12dp"
android:foreground="?attr/selectableItemBackground"
>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/pokedex_row_text_view"
android:layout_margin="10sp"
/>
</LinearLayout>
background of row
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:left="8dp"
android:right="3dp"
android:top="8dp"
android:bottom="2dp">
<shape android:shape="rectangle">
<solid android:color="#CBAAAAAA"
android:width="1dp"/>
<corners android:radius="5dp" />
</shape>
</item>
<item
android:left="5dp"
android:right="5dp"
android:top="5dp"
android:bottom="5dp">
<shape android:shape="rectangle">
<solid android:color="#android:color/white" />
<corners android:radius="5dp" />
</shape>
</item>
</layer-list>
You could use the ripple tag instead of layer-list to acheive the required behaviour.
Note: This will work only for API 21+(Lollipop).
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
tools:targetApi="lollipop" android:color="?colorControlNormal">
<item
android:left="8dp"
android:right="3dp"
android:top="8dp"
android:bottom="2dp">
<shape android:shape="rectangle">
<solid android:color="#CBAAAAAA"
android:width="1dp"/>
<corners android:radius="5dp" />
</shape>
</item>
<item
android:left="5dp"
android:right="5dp"
android:top="5dp"
android:bottom="5dp">
<shape android:shape="rectangle">
<solid android:color="#android:color/white" />
<corners android:radius="5dp" />
</shape>
</item>

How to achieve shadow over the card view?

I am trying to achieve following layout :
I want to expand each view on click.
How do I obtain the shadow over each view?
I have tried the following drawable :
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<gradient
android:startColor="#cacaca"
android:centerColor="#b6b6b6"
android:endColor="#e9e9e9"
/>
</shape>
<gradient
android:startColor="#6586F0"
android:centerColor="#D6D6D6"
android:endColor="#4B6CD6"
android:angle="90"/>
</item>
<item
android:left="0dp"
android:right="0dp"
android:top="5dp"
android:bottom="2dp">
<shape android:shape="rectangle">
<solid android:color="#ffffff"/>
<corners android:radius="20dp"/>
</shape>
</item>
</layer-list>
But it is showing following view :
Please help me to achieve the proper view.
you can achieve this by nesting multiple cardViews inside the FrameLayout.
Change the android:layout_marginTop and app:cardElevation properties to give this stack effect.
Try below code :
For Drawable:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Drop Shadow Stack -->
<item>
<shape android:shape="rectangle">
<padding
android:left="1dp"
android:right="1dp"
android:top="1dp" />
<corners android:topLeftRadius="20dp"
android:topRightRadius="20dp"/>
<solid android:color="#14000029" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<padding
android:left="1dp"
android:right="1dp"
android:top="1dp" />
<corners android:topLeftRadius="20dp"
android:topRightRadius="20dp"/>
<solid android:color="#14000029" />
</shape>
</item>
<item>
<shape
android:shape="rectangle">
<padding
android:left="1dp"
android:right="1dp"
android:top="1dp" />
<corners android:topLeftRadius="20dp"
android:topRightRadius="20dp"/>
<solid android:color="#14000029" />
</shape>
</item>
<!-- Background -->
<item>
<shape
android:shape="rectangle">
<corners android:topLeftRadius="20dp"
android:topRightRadius="20dp"/>
<solid android:color="#android:color/white"/>
</shape>
</item>
</layer-list>
Code in Layout file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".CardViewShadowActivity"
android:layout_marginTop="30dp">
<LinearLayout
android:id="#+id/linear_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingTop="10dp"
android:paddingBottom="30dp"
android:background="#drawable/custom_bg">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello"/>
</LinearLayout>
<LinearLayout
android:id="#+id/linear_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingTop="10dp"
android:paddingBottom="30dp"
android:background="#drawable/custom_bg"
android:layout_below="#id/linear_1"
android:layout_marginTop="-20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello"/>
</LinearLayout>
<LinearLayout
android:id="#+id/linear_3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingTop="10dp"
android:paddingBottom="30dp"
android:background="#drawable/custom_bg"
android:layout_below="#id/linear_2"
android:layout_marginTop="-20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello"/>
</LinearLayout>
<LinearLayout
android:id="#+id/linear_4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingTop="10dp"
android:paddingBottom="30dp"
android:background="#drawable/custom_bg"
android:layout_below="#id/linear_3"
android:layout_marginTop="-20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello"/>
</LinearLayout>
</RelativeLayout>
Customize layout and drawable according to your need.
Output for above code is:
I hope this helps you

Rounded Corner Bottom TextView inside CardView

I am using CardView to show List Items, where each and every List Item contains two textviews, namely - BOOK NOW/BOOK and DETAIL/DETAILS.
I would like to achieve rounded bottom TextView, but getting in rectangular shape
I have to design something like this:
Here is my XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.CardView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:layout_margin="5dp"
app:cardCornerRadius="5dp"
app:cardElevation="2dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_weight="1">
.......
<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_marginTop="5dp"
android:background="#color/more"
android:layout_weight="1">
<TextView
android:id="#+id/btnBook"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="BOOK"
android:textColor="#android:color/background_light"
android:padding="5dp"
android:background="#null"
android:textAppearance="?android:textAppearanceMedium"
android:gravity="center" />
<TextView
android:id="#+id/btnDetail"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="DETAILS"
android:background="#null"
android:textColor="#android:color/background_light"
android:padding="10dp"
android:textAppearance="?android:textAppearanceMedium"
android:gravity="center" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
Where I have to make change to get it done ?
set this background to the LinearLayout containing the textViews
<item>
<shape android:shape="rectangle">
<solid android:color="#color/colorPrimary" />
<corners android:bottomLeftRadius="cardview_corner_radius_value"
android:bottomRightRadius="cardview_corner_radius_value" />
</shape>
</item>
and add background of TextView as transparent
You have to make selector for this in drawable folder.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape
android:shape="rectangle">
<stroke android:width="2dp" android:color="#color/more" />
<dotted android:color="#00FF0000" />
<padding android:bottom="1dp"/>
</shape>
</item>
</layer-list>
Then set background to your view. Use this
android:background="#drawable/corner_selector"
instead of
android:background="#color/more"
make a file rounded_border.xml in drawable folder
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<stroke
android:width="1dp"
android:color="#color/common_border_color" />
<solid android:color="#fff" />
<padding
android:left="1dp"
android:right="1dp"
android:top="1dp" />
<corners android:radius="5dp" />
</shape>
and keep it as a background of linear layout
<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_marginTop="5dp"
android:background="#drawable/rounded_border"
android:layout_weight="1">
1. make button.xml file and put it in drawable folder
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_pressed="true" >
<shape android:shape="rectangle" >
<corners android:radius="3dip" />
<stroke android:width="1dip" android:color="#5e7974" />
<gradient android:angle="-90" android:startColor="#345953" android:endColor="#689a92" />
</shape>
</item>
<item android:state_focused="true">
<shape android:shape="rectangle" >
<corners android:radius="3dip" />
<stroke android:width="1dip" android:color="#5e7974" />
<solid android:color="#58857e"/>
</shape>
</item>
<item >
<shape android:shape="rectangle" >
<corners android:radius="3dip" />
<stroke android:width="1dip" android:color="#5e7974" />
<gradient android:angle="-90" android:startColor="#8dbab3" android:endColor="#58857e" />
</shape>
</item>
</selector>
2. then change your xml background of Linearlayout
android:background="#color/more"
to
android:background="#drawable/button"
Try with this simplest way to do this your Layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="#+id/btn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btnbackground"
android:layout_margin="20dp"
android:text="My Profile"
/>
</LinearLayout>
after that make a xml in drawable folder btnbackground.xml
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/llabeforeclick3"
android:state_pressed="true"/>
<item android:drawable="#drawable/llaafterclick3"/>
</selector>
then make another llabeforeclick3.xml in drawable directory
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#19384A" >
</solid>
<corners
android:bottomLeftRadius="10dp"
android:bottomRightRadius="10dp"
android:topRightRadius="10dp"
android:topLeftRadius="10dp" />
<stroke
android:width="0dp"
android:color="#19384A" />
<padding
android:left="4dp"
android:top="4dp"
android:right="4dp"
android:bottom="4dp"
android:color="#19384A" />
</shape>
after that make another xml llaafterclick3.xml in drawable
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
//background color
<solid android:color="#204A60" >
</solid>
<corners
android:bottomLeftRadius="10dp"
android:bottomRightRadius="10dp"
android:topRightRadius="10dp"
android:topLeftRadius="10dp" />
//before clicked
<gradient
android:angle="45"
android:centerColor="#204A60"
android:centerX="20"
android:centerY="20"
android:endColor="#204A60"
android:gradientRadius="25"
android:startColor="#204A60" />
</shape>
if some buddy wants to make more rounded corners then use to increase size of
android:bottomLeftRadius="10dp"
android:bottomRightRadius="10dp"
android:topRightRadius="10dp"
android:topLeftRadius="10dp"
That solve here your color code is depends on you you need to put color code only and radious.

Pass color attribute from custom view to drawable shape in Android

I have created a custom view that uses two <shape>'s as background in the view xml. Right now I have hardcoded the <solid color=""/> of the shape, but I would like to pass the color as an argument from code to the custom view and forward to the shape.
How do I achieve this? I'd like to pass a color reference to both #+id/rectangle and #+id/triangle from code.
Shape:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="1dp"/>
<solid android:color="#color/giddyologyOrange"/>
<padding
android:left="0dp"
android:top="0dp"
android:right="0dp"
android:bottom="0dp"
/>
<size android:height="60dp"
/>
<stroke
android:width="1dp"
android:color="#C95800"
/>
</shape>
View:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/rectangle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/rectangle"
android:orientation="horizontal"
android:padding="5dp">
<ImageView
android:id="#+id/iconImageView"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center_vertical|left"
android:contentDescription="Icon"
android:src="#drawable/iconplaceholder"
android:scaleType="fitCenter"/>
<View
android:id="#+id/spaceView"
android:layout_height="match_parent"
android:layout_width="10dip"/>
<TextView
android:id="#+id/labelTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|left"
android:textColor="#color/white"
android:gravity="center|left"
android:textSize="16dip"
android:maxWidth="150dip"
android:text="This is a really long text that should wrap"/>
</LinearLayout>
<View
android:id="#+id/triangle"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="-1dp"
android:background="#drawable/triangle"
android:rotation="180"/>
</LinearLayout>
did you try this?
LinearLayout myView;
myView = (LinearLayout)findViewById(R.id.rectangle);
myView.setBackgroundColor(current_color);
I have a layout that has an ImageButton
<ImageButton
android:id="#+id/color_swatch"
android:layout_width="#dimen/standard_btn_width"
android:layout_height="#dimen/standard_btn_width"
android:background="#drawable/checker_tile"
android:contentDescription="#string/paint"
android:src="#drawable/paint" />
my src is a layer-list drawable--
layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle" >
<stroke
android:width="2dp"
android:color="#FF999999" />
<solid android:color="#00000000" />
<padding
android:bottom="0dp"
android:left="0dp"
android:right="0dp"
android:top="0dp" />
</shape>
</item>
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<stroke
android:width="4dp"
android:color="#FF999999" />
<solid android:color="#00000000" />
<corners android:radius="0dp" />
</shape>
</item>
</layer-list>
the background is a layer-list drawable-
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<gradient
android:type="radial" android:gradientRadius="500"
android:startColor="#17568A"
android:endColor="#494C4F" />
</shape>
</item>
<item>
<bitmap
android:src="#drawable/checkerpattern"
android:tileMode="repeat" />
</item>
</layer-list>
I am able to setBackgroundColor to any color with 50% opacity and see the checkerpattern below
I ended up using a color filter to colorize the background image.
rectangle.getBackground().setColorFilter(color, PorterDuff.Mode.SRC);
Since the color comes from my model object this seemed like a pretty easy and maintainable solution.

Categories

Resources