How to change layout of spinner in Android

后端 未结 3 972
甜味超标
甜味超标 2021-02-06 14:32

\"\"

When O click on this spinner it gives a big dropdown:

3条回答
  •  一向
    一向 (楼主)
    2021-02-06 14:48

    This is a good article : Customizing the Action Bar

    And also you can try this :

    Design you own customized drawable for spinner background and apply to it. For spinnerbackground.xml images you can refer the images from the SDK. recreate the images as per your design requirements

    "Android-sdk\platforms\android-9\data\res\drawable-hdpi\*.png"

    spinnerbackground.xml

    
        
        
        
        
        
        
        
    
    

    then for spinner widget apply your custom drawable:

    
        
    

    Edited :

    
        
    

    where popup_background is : enter image description here

    and

    Design your custom layout for spinner texts as (name : custom_spiner.xml)

    
    
    
    

    and use it as

    adapter.setDropDownViewResource(R.layout.custom_spiner);
    

    in your code.

    Edited 2:

    if you want to do this using java code read about PopupWindow

    And may be useful : custom-spinner

提交回复
热议问题