[英]Android textview shadow doesn't work using style.xml
I have a textview that I set its style to a style I made with a shadow. 我有一个textview,我将它的样式设置为我用阴影制作的样式。 I declared the settings I want in the style.xml
InfoTextstyle
and set the textview style to the style but it doesn't work. 我在style.xml
InfoTextstyle
声明了我想要的设置,并将textview样式设置为样式,但它不起作用。
This is the style.xml : 这是style.xml :
<style name="InfoTextStyle" parent="AppBaseTheme">
<item name="android:textColor">#fff</item> <- works
<item name="android:textSize">18sp</item> <- works
<item name="android:shadowColor">#ff0000</item> <- don't works*
<item name="android:shadowRadius">5.0</item> <- *
<item name="android:shadowDx">2.0</item> <- *
<item name="android:shadowDy">2.0</item> <- *
</style>
& this is the activity_main.xml : 这是activity_main.xml :
<TextView
android:id="@+id/brightness"
style="@style/InfoTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginTop="15dp"
android:text="@string/brightness"
android:textAppearance="?android:attr/textAppearanceMedium" />
I'm new to android, so I'm not sure what's the problem. 我是android的新手,所以我不确定是什么问题。
A few things to try: 一些事情要尝试:
Use this XML code in your TextView declaration instead of using Styles 在TextView声明中使用此XML代码而不是使用样式
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="A light blue shadow."
android:shadowColor="#00ccff"
android:shadowRadius="1.5"
android:shadowDx="1"
android:shadowDy="1"
/>
-android:shadowColor Shadow color in the same format as textColor. -android:shadowColor阴影颜色与textColor的格式相同。
-android:shadowRadius Radius of the shadow specified as a floating point number. -android:shadowRadius指定为浮点数的阴影半径。
-android:shadowDx The shadow's horizontal offset specified as a floating point number. -android:shadowDx阴影的水平偏移量指定为浮点数。
-android:shadowDy The shadow's vertical offset specified as a floating point number. -android:shadowDy指定为浮点数的阴影垂直偏移量。
Also use this link to pick your Color code http://www.w3schools.com/tags/ref_colorpicker.asp 也可以使用此链接选择您的颜色代码http://www.w3schools.com/tags/ref_colorpicker.asp
EDIT: 编辑:
TextView textv = (TextView) findViewById(R.id.textview1);
textv.setShadowLayer(1, 0, 0, Color.BLACK);
Also take a look at this link for Style way https://stackoverflow.com/a/2487340/1364896 另请查看样式方式https://stackoverflow.com/a/2487340/1364896的此链接
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.