I need to draw outline stroke on text in MaterialTextView. I saw that it is not that easy to do in older questions. (In this for example: How do you draw text with a border on a MapView in Android?). Is something changed right now? If we need to set it programmatically, can anyone help me with Kotlin method for this and explain how to make it? I saw answers but I don't know where to create attrs.xml file I never used it before.
            Asked
            
        
        
            Active
            
        
            Viewed 341 times
        
    1
            
            
        - 
                    Does this answer your question? [Beautiful Stroked Text in Android](https://stackoverflow.com/questions/29506643/beautiful-stroked-text-in-android) – Ivo Dec 17 '21 at 08:40
- 
                    @IvoBeckers not really. It's Java and i need to make standard outline not custom one – SoulReaver313 Dec 17 '21 at 08:51
- 
                    there isn't a standard as far as I know. And it being Java shouldn't matter. All Java can be easily converted to Kotlin – Ivo Dec 17 '21 at 08:58
1 Answers
1
            
            
        You could define a rectangle shape in the res/drawable folder, let's call it rect_border.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >
    <stroke android:width="2dp" 
        color="#000" />
</shape>
And use it as android:background for your MaterialTextView:
<MaterialTextView
    ...
    android:background="@drawable/rect_with_border" />
 
    
    
        lpizzinidev
        
- 12,741
- 2
- 10
- 29
 
    