Shadow Separator Between Android Fragments

前端 未结 2 1250
春和景丽
春和景丽 2021-01-29 19:20

I have a layout similar to the ICS Gmail app for tablets (ListFragment on the left and content on the right) and I was wondering how I could go about constructing t

2条回答
  •  星月不相逢
    2021-01-29 19:40

    Just to let everyone know (because there seems to be a lack of information out there on this topic), this is achieved within the background selector XML of the individual list rows' view. For example, this is the main screen's layout,

    
    
        ...
    
    
    

    But the magic comes in the list_item_selector:

    
        
        
        
    
    

    By defining these as 9-patch drawables like this, you can have each list item contribute it's width worth of shadow to that line in the middle, and when it is activated, that segment of shadow will be replaced by an arrow. I hope this helps someone, as it's sure helped me!

提交回复
热议问题