How to set the size of an AutoCompleteTextView Result?

前端 未结 3 1178
暗喜
暗喜 2020-12-10 15:36

Does anybody know How to set the size of an AutoCompleteTextView Result ?

\"enter

相关标签:
3条回答
  • 2020-12-10 16:21
    private ArrayAdapter<String> autoCompleteAdapter = new ArrayAdapter<String>
                              (this,android.R.layout.simple_list_item_1, yourList) {
    
        public View getView(int position, View convertView, ViewGroup parent) {
            View v = super.getView(position, convertView, parent);
    
            ((TextView) v).setTextSize(14);                             
            Typeface Type = getFont () ;  // custom method to get a font from "assets" folder
            ((TextView) v).setTypeface(Type);               
            ((TextView) v).setTextColor(YourColor);                                             
            ((TextView) v) .setGravity(Gravity.LEFT|Gravity.CENTER_VERTICAL);
    
            return v;
        }           
    };
    
     YourAutoCompleteView.setAdapter(autoCompleteAdapter);
    
    0 讨论(0)
  • 2020-12-10 16:40

    Just add android:dropDownHeight="size" for AutoCompleteTextView in xml file.

    0 讨论(0)
  • 2020-12-10 16:41

    The best way is to create your own xml file with a customized design, such as "dropdown.xml"

    <?xml version="1.0" encoding="utf-8"?>
    <TextView 
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/textAutoComplete"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#F3F5E1"
        android:gravity="center_vertical"
        android:padding="5dp" />
    

    and in your code use this

    AutoCompleteTextView etChoose= (AutoCompleteTextView) findViewById(R.id.etChoose);
    ArrayAdapter<String> adapterChoose = new ArrayAdapter<String>(this,R.layout.dropdown, ChooseList);
    
    0 讨论(0)
提交回复
热议问题