android spinner change font typeface

前端 未结 5 2079
被撕碎了的回忆
被撕碎了的回忆 2020-12-06 14:23

i\'m going to change text typeface to arialbold in my spinner how i\'m going to do so. Below is my code :-

ArrayAdapter genderAdap = Arra         


        
5条回答
  •  无人及你
    2020-12-06 15:15

    For changing the font of spinner items, you have to use custom spinner

    try as to set custom Typeface for all TextView's in spinner :

    Typeface typeface;
    font_name_Adapter= new ArrayAdapter
                    (this,android.R.layout.simple_spinner_item,ARRLIST_FONTS)
           {
                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);
    
                    if(position<=ARRLIST_FONTS.size()){
                     typeface = 
                      Typeface.createFromAsset(Your_Current_Activity.this.getAssets(),
                                   "fonts/yourfontname.ttf"); 
                         ((TextView) v).setTypeface(typeface);
                       }
    
                        return v;
         }
    

提交回复
热议问题