Contextual Actionbar styles

前端 未结 4 1568
轮回少年
轮回少年 2020-11-28 23:18

I\'m looking for style information on the Contextual Action bar (CAB). I just need to change the colour of the text in fact..

4条回答
  •  再見小時候
    2020-11-28 23:40

    To change the color/etc of the text in a contextual action bar:

    public boolean onCreateActionMode(ActionMode mode, Menu menu) {
      //mode.setTitle("Contextual Action Bar"); (replace this call)
      TextView tv= (TextView)getLayoutInflater().inflate(R.layout.contextual_title, null);
      tv.setText("Contextual Action Bar");
      mode.setCustomView(tv);
    

    where layout/contextual_title.xml contains a single TextView with your desired color/size/style etc

    In fact, almost everything in a contextual action bar can be styled. The only problem is that searching for the word 'contextual' leads nowhere useful. The relevant styling features are all called "actionMode...". Here are some I used (defined in my Theme.)

    @drawable/check
    @drawable/ic_menu_cut_holo_dark
    @drawable/ic_menu_copy_holo_dark
    @drawable/ic_menu_paste_holo_dark
    @drawable/ic_menu_selectall_holo_dark
    @drawable/contextual
    @style/MyCloseButton
    
    
    @null
    @drawable/bar_selector
    @drawable/bar_selector      
    
    
    
    
    
    
    
    
    
    

    You can easily set your own text-editing cut/paste/copy/selectall icons, the bar background, and the icon background that changes color when you press the icons(bar_selector above). The icons are ImageViews, not buttons, and the edit id's (and the pressable background) are attached to the ImageView's parent (one parent per view) which is an 'internal' type.

    It's never clear what goes where in the styles--I found where selectableItemBackground was in the platform Themes.xml, and copied and modified the drawable pointed at.

提交回复
热议问题