Shadow Separator Between Android Fragments

前端 未结 2 1248
春和景丽
春和景丽 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:59

    I'm looking to do the same thing that you're trying to do; create an effect that one fragment is "closer" than another.

    Roboguy's answer handles how to have the white arrow "selector" on the list item; I'll try to be more specific about shadows. Another good example of the use of background selectors can be seen in the source code of the Google IO 2011 App. Once you have the source, look at the fragment_dashboard.xml icon selectors.

    The shadow separator is a gradient, applied to the left side of a view. There are two parts;

    First, the "shadow" itself:

    res/shadow_left.xml

    
    
    
    
    

    Then, to actually apply it to a layout:

    layout/my_lower_layer

    
    
    
    
    
    

    This has to be done with a relative layout (to my knowledge). If you're using a linear layout, you can wrap the whole linearLayout inside of a relative layout, and then add the with the gradient.

    Note that, if you do this, the gradient has to go below the ; otherwise, the gradient will be drawn under the linear layout, so you won't see it.

提交回复
热议问题