Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Programatically Stroke
    primarykey
    data
    text
    <p>I want to draw a black stroke on my text in Android.</p> <p>I have seen this example: <a href="https://stackoverflow.com/questions/1723846/how-do-you-draw-text-with-a-border-on-a-mapview-in-android">How do you draw text with a border on a MapView in Android?</a></p> <p>Where the solution overrides onDraw() to create the stroke.</p> <p>The problem is, I'm still relatively starting out in Android, and I have no idea how to transition to using that solution.</p> <p>In my onCreate I set the text typeface (it's custom):</p> <pre><code>@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeatures(); // Set content view and component listeners setContentView(R.layout.meme_maker); setListeners(); context = this; Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/Impact.ttf"); TextView mmt = (TextView) findViewById(R.id.meme_maker_title); TextView ttc = (TextView) findViewById(R.id.top_text_canvas); TextView tbc = (TextView) findViewById(R.id.bottom_text_canvas); ttc.setTypeface(tf); tbc.setTypeface(tf); mmt.setTypeface(tf); } </code></pre> <p>And I have an onClickListener where I change the text content of the TextView, based on the user writing the text he/she wants in a TextEntry and clicking a button afterwards.</p> <pre><code>ImageView ii = (ImageView) findViewById(R.id.insert_image); ii.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { EditText tt = (EditText) findViewById(R.id.top_text_text); EditText bt = (EditText) findViewById(R.id.bottom_text_text); TextView ttc = (TextView) findViewById(R.id.top_text_canvas); TextView btc = (TextView) findViewById(R.id.bottom_text_canvas); ttc.setText(tt.getText().toString().toUpperCase()); btc.setText(bt.getText().toString().toUpperCase()); } }); </code></pre> <p>It's pretty straightforward so far. My question is: how to insert the stroke of the text? Where? Do I need to create a Canvas and Paint objects?</p> <p>Thank you</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload