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

前端 未结 7 949
独厮守ぢ
独厮守ぢ 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:17

    Add divider for the Listview item and padding :

     android:divider="@android:color/transparent"
        android:dividerHeight="1dip"
    

    Add RelativeLayout into your LinearLayout for ListItem with some desired padding :

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="100dp"
        android:orientation="vertical"
        android:padding="3dp" >
    
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
    
            android:background="@drawable/rowshadow" >
    
            <TextView
                android:id="@+id/title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
    ...
    

    Add Background to the listview item , like :

    <?xml version="1.0" encoding="utf-8"?>
       <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
         <item >
            <shape 
              android:shape="rectangle">
                  <solid android:color="@android:color/darker_gray" />
                  <corners android:radius="0dp"/>
            </shape>
         </item>
         <item android:right="1dp" android:left="1dp" android:bottom="2dp">
            <shape 
              android:shape="rectangle">
                  <solid android:color="@android:color/white"/>
                  <corners android:radius="0dp"/>
            </shape>
         </item>
       </layer-list>
    

    Use https://github.com/elcrion/demo.cardlistview as an example. It is somehow close to google style

    0 讨论(0)
提交回复
热议问题