Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Can you elaborate on what kind of styling you are seeking to apply? </p> <p>If it's just basic text styling, you could probably build a <code>Spannable</code> and set the completion hint with the result, since it accepts a <code>CharSequence</code>. An example of building a <code>Spannable</code> and apply styles to it is illustrated in <a href="https://stackoverflow.com/questions/8005599/how-to-display-the-value-of-string-with-its-title-using-html-format/8006405#8006405">this post</a>.</p> <p>If you're looking for a way to actually manipulate the parameters of the <code>TextView</code> (e.g. padding), the <a href="http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/1.5_r4/android/widget/AutoCompleteTextView.java" rel="nofollow noreferrer">source code</a> of <code>AutoCompleteTextView</code> seems to provide a hint (pun intended).</p> <pre><code>private View getHintView(Context context) { if (mHintText != null &amp;&amp; mHintText.length() &gt; 0) { final TextView hintView = (TextView) LayoutInflater.from(context).inflate( mHintResource, null).findViewById(com.android.internal.R.id.text1); hintView.setText(mHintText); hintView.setId(HINT_VIEW_ID); return hintView; } else { return null; } } </code></pre> <p>This reveals that Android looks for the id <code>text1</code> in the resource reference you specify. The most basic version of such a resource would contain nothing but a <code>TextView</code> with this id:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/text1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dp" android:textColor="#FF0000" android:textSize="16sp" /&gt; </code></pre> <p>Save above in a layout file (e.g. <code>completion_hint_view.xml</code>) and reference it as follows from your <code>AutoCompleteTextView</code>:</p> <pre><code>&lt;AutoCompleteTextView android:id="@+id/autocomplete_textview" android:layout_width="fill_parent" android:layout_height="wrap_content" android:completionHintView="@layout/completion_hint_view"/&gt; </code></pre> <p>This second option is probably the easiest to use and will give you full access to the TextView's parameters. If you need to apply multiple styles to the text in this view, you can incorporate the first suggestion, as that will give you more flexibility.</p> <p>If neither of these suggestions suffice, I can think of some less elegant work arounds that would probably allow you to get the same result.</p>
 

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