1

I have TextView (word is : "Wed") which I created over xml and I want to set white outline border like on this ss:

enter image description here

How can I do that?

iWizard
  • 6,816
  • 19
  • 67
  • 103
  • Look at this: [Link](https://stackoverflow.com/questions/3182393/android-textview-outline-text) Everything is explained here already. Hope you can do it. – silvia_aut Sep 17 '13 at 11:41
  • You mean on second anwser with "MagicTextView" or accepted answer? – iWizard Sep 17 '13 at 11:43
  • You can decide it. Would work both. But I think the "Magic" thing would be that would you are looking for. – silvia_aut Sep 17 '13 at 11:49
  • Can't say why. But read this: http://stackoverflow.com/questions/1717489/android-hello-gallery-tutorial-r-styleable-cannot-be-resolved – silvia_aut Sep 17 '13 at 13:07
  • Or this: http://stackoverflow.com/questions/6675403/r-styleable-can-not-be-resolved-why – silvia_aut Sep 17 '13 at 13:07
  • Solved, I have to create attrs.xml and add there content from this example project – iWizard Sep 17 '13 at 13:10

1 Answers1

3

You should be able to add the style, like this (taken from source code for Ringdroid):

 <style name="AudioFileInfoOverlayText">
    <item name="android:paddingLeft">4px</item>
    <item name="android:paddingBottom">4px</item>
    <item name="android:textColor">#ffffffff</item>
    <item name="android:textSize">12sp</item>
    <item name="android:shadowColor">#000000</item>
    <item name="android:shadowDx">1</item>
    <item name="android:shadowDy">1</item>
    <item name="android:shadowRadius">1</item>
  </style>

And in your layout, use the style like this:

 <TextView android:id="@+id/info"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       style="@style/AudioFileInfoOverlayText"
       android:gravity="center" />

Edit: the source code can be viewed here: http://code.google.com/p/ringdroid/

Edit2: To set this style programmatically, you'd do something like this (modified from this example to match ringdroid's resources from above)

TextView infoTextView = (TextView) findViewById(R.id.info);
infoTextView.setTextAppearance(getApplicationContext(),  
       R.style.AudioFileInfoOverlayText);

The signature for setTextAppearance is

public void setTextAppearance (Context context, int resid)

Since: API Level 1 Sets the text color, size, style, hint color, and highlight color from the specified TextAppearance resource.

Deepak
  • 192
  • 1
  • 2
  • 18