我尝试了以下代码,但阴影不会出现,它只是显示为常规的白色文本。
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);
样式文件是
<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>
相对布局和阴影是否存在问题?