How to create Google + cards UI in a list view?

前端 未结 7 1046
独厮守ぢ
独厮守ぢ 2020-12-12 11:15

I want to create a listView of cards, but after reading this blog post goolge-plus-layout, I\'m cards are a viable solution for a list of anything. The animation part seems

7条回答
  •  孤街浪徒
    2020-12-12 12:08

    EDIT: Google provides a nice class called CardView. I didn't check it but it looks promising.

    Here's the previous way, which also works fine (that's what I wrote before the edit) :

    There is a nice tutorial here and a nice sample of it here .

    in short , these are the files you can create:

    listView definition:

    android:divider="@null"
    android:dividerHeight="10dp"
    android:listSelector="@android:color/transparent" 
    android:cacheColorHint="@android:color/transparent"
    android:headerDividersEnabled="true"
    android:footerDividersEnabled="true"
    

    also this:

    m_list.addHeaderView(new View(this));
    m_list.addFooterView(new View(this));
    

    res/drawable/selector_card_background.xml

    
    
    
       
    
       
    
    

    listView item :

    res/layout/list_item_card.xml

    
    
    
       
    
          
    
          
    
          
       
    
    

    res/drawable/layer_card_background_selected.xml

    
    
        
            
                
                
            
        
    
        
            
                
                
            
        
    
    

    res/drawable/layer_card_background.xml

    
    
        
            
                
                
            
        
    
        
            
                
                
            
        
    
    

提交回复
热议问题