Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force vertical scrollbar to show if AutoCompleteTextView results can scroll?

I've got an AutoCompleteTextView in my app and I've been tasked with forcing the vertical scroll bar to always show if the results retrieved by said textview are numerous enough to be scrolled (i.e. there are more results than can fit at once in the autocreated listview).

I've tried adding the following xml attributes to the AutoCompleteTextView itself to no avail:

fadeScrollbars="false"
scrollbarFadeDuration="0"
scrollbarAlwaysDrawVertical="true"

I'm thinking if I could somehow obtain a reference to the listview created automatically for the AutoCompleteTextView and applying one or more of the above attributes to it that I could force the scrollbar to always show but I have no idea how to get a reference to that listview.

Thanks

UPDATE

In the Adapter I created for this AutoCompleteTextView, in the Overridden getView() method, I have a reference to the parent view. I can set those attributes above programatically on the parent and I get the desired functionality, the downside is that those attributes are set each time getView is called which isn't the most efficient?

like image 612
Ryan Avatar asked May 14 '14 15:05

Ryan


1 Answers

I have tried styles but they don't work properly, so your coded way seems like the only possibility. But the group is given on every time, so you could just add a boolean for this:

public View getView(int position, View convertView, ViewGroup parent) {
        //Change the list attr programmatically becuase sometimes Android sucks :/
        if (!_changedListAttr) {
            _changedListAttr = true;

            ListView list = (ListView) parent;
            list.setBackgroundResource(R.color.color_white);
            list.setVerticalScrollBarEnabled(false);
            list.setDividerHeight(0);
        }
like image 129
Shachar Silbert Avatar answered Sep 24 '22 02:09

Shachar Silbert