10
我動態創建一個TextView,並使用在此發佈的方法設置陰影吧:Android - shadow on text?無法設置TextView的影子編程
但它不工作。應用樣式(將textSize項目用於測試,並且工作正常),但陰影不顯示。
的TextView:
TextView tv = new TextView(this);
RelativeLayout.LayoutParams layoutPars = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
layoutPars.addRule(RelativeLayout.CENTER_VERTICAL);
tv.setTextColor(0xffffffff);
tv.setText(label);
tv.setTextSize(11);
tv.setTextAppearance(getApplicationContext(), R.style.BlackShadow);
風格:
<style name="BlackShadow">
<item name="android:shadowColor">#ff000000</item>
<item name="android:shadowRadius">1</item>
<item name="android:shadowDx">-1</item>
<item name="android:shadowDy">-1</item>
<item name="android:textSize">26dip</item>
</style>
我在做什麼錯?
why-1.5f?它看起來不像我的打字錯誤 – Alpaslan 2015-07-28 11:09:05
@Alpaslan這些值僅作爲示例,根據您的要求更改這些值。 – 2015-08-01 06:56:40