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