Reputation: 31
I have a textview that I set its style to a style I made with a shadow. I declared the settings I want in the style.xml InfoTextstyle
and set the textview style to the style but it doesn't work.
This is the 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:
<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.
Upvotes: 3
Views: 4343
Reputation: 7230
A few things to try:
Upvotes: 1
Reputation: 10009
Use this XML code in your TextView declaration instead of using Styles
<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:shadowRadius Radius of the shadow specified as a floating point number.
-android:shadowDx The shadow’s horizontal offset specified as a floating point number.
-android:shadowDy The shadow’s vertical offset specified as a floating point number.
Also use this link to pick your Color code 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
Upvotes: 0