3
我試過下面的代碼,但投影不會出現,它只是作爲普通的白色文本出現。投影不顯示爲TextView
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>
有相對佈局的問題,也許陰影?
也許你應該嘗試降低模糊半徑(shadowRadius)爲0.1 - 0.3來看看它 – androidu
沒有效果。即使改變這些值,陰影也不會出現 – Shane