Drop shadow not showing up for TextView

1.9k Views Asked by At

I've tried the following code but the drop shadow will not show up, it just appears as regular white text.

TextView newsTitle = new TextView(mCtx);
newsTitle.setText(newsitems[position].getTitle());
newsTitle.setTextAppearance(mCtx, R.style.TextWithDropShadow);
RelativeLayout.LayoutParams newsTitleParams = 
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
newsTitleParams.addRule(RelativeLayout.ABOVE, linLayout.getId());
newsTitleParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
newsTitle.setLayoutParams(newsTitleParams);
relLayout.addView(newsTitle);

And the style file is

<style name="TextWithDropShadow">
    <item name="android:textColor">#ffffff</item>
    <item name="android:textStyle">bold</item>
    <item name="android:shadowColor">#000000</item>
    <item name="android:shadowDx">2</item>
    <item name="android:shadowDy">2</item>
    <item name="android:shadowRadius">2</item>

Is there an issue with relative layouts and drop shadows perhaps?

1

There are 1 best solutions below

0
On BEST ANSWER

Although this doesn't answer the problem at hand, a different approach works.

Adding this line

newsTitle.setShadowLayer(15, 0, 0, Color.BLACK);

Would still be interesting to know what I was doing wrong using the styles.