How to keep shader from overriding style applied in xml
Goal:
Programmatically and conditionally change the color of text through an array adapter to a specific gradient.
Problem:
When I do this with the following code, it overrides the style applied in the XML that I need to have the text stand out visually.
styles.xml
<style name="OverlayText"> <item name="android:paddingLeft">4px</item> <item name="android:paddingBottom">4px</item> <item name="android:textColor">#ffffffff</item> <item name="android:textSize">12sp</item> <item name="android:shadowColor">#000000</item> <item name="android:shadowDx">1</item> <item name="android:shadowDy">1</item> <item name="android:shadowRadius">1</item> </style>
xml:
<TextView android:id="@+id/goc" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/image" android:layout_marginBottom="88dp" android:fontFamily="@font/font" android:paddingLeft="9dp" android:textColor="@color/light_green_color" android:textSize="30dp" tools:text="goc" style="@style/OverlayText"/>
code in array adapter:
Shader shader = new LinearGradient(0, 0, 0, holder.goc.getLineHeight(), getContext().getResources().getColor(R.color.light_bronze), getContext().getResources().getColor(R.color.dark_bronze), Shader.TileMode.REPEAT); holder.goc.getPaint().setShader(shader);
As far as I can tell, the style applied in the XML is being replaced by the shader applied in the array adapter. How would I go about keeping both? Any answers/suggestions much appreciated. Thank you!