nits.kk
nits.kk

Reputation: 5336

How to change the text Size of Spinner run time

I have a android spinner. I want to change the size of the spinner text (selected text from the dropdown) run time. I have a button on whose onCLick event I want to do the size change of few things. All other texts are changing by setTextSize() but there are issues with spinner. I have taken the reference of the textview used in getView() of my custom spinner adapter. I apply setTextSize() on it. The first Time it changes the size of he spinner but by again pressing the button ever thing (other textViews on the screen) change their size but not the spinner. Please help..

Regards, Krishna

Upvotes: 1

Views: 2227

Answers (2)

Hemantvc
Hemantvc

Reputation: 2119

try this code 
    Spinner sp_state = new Spinner(this);
    RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
    sp_state.setLayoutParams(lp);

    ArrayAdapter<String> state_Adapter= new ArrayAdapter<String>(getParent(),android.R.layout.simple_spinner_item,ARRLIST_STATE){
          public View getView(int position, View convertView,ViewGroup parent) {
                View v = super.getView(position, convertView, parent);
                ((TextView) v).setTextSize(12);
                ((TextView) v).setTextColor(Color.WHITE);
                return v;
        }


    };

state_Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); sp_state.setAdapter(driver_state_Adapter);

Upvotes: 2

Tofeeq Ahmad
Tofeeq Ahmad

Reputation: 11975

If you are using customize Adapter.Then you have to use one Base Adapter class like in List View.The xml file you inflate, can be used as you want.You can increase size there

Edited Refer to this link for more details

Upvotes: 1

Related Questions