[英]Android L cards using CardView
我正在使用新的Android L SDK玩,但是我不知道如何實現CardView。 好像我缺少什么-非常感謝任何建議!
到目前為止,我已聲明以下內容是我的活動的一部分:
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:layout_below="@+id/waitingHeader"
card_view:cardCornerRadius="4dp">
<LinearLayout
android:id="@+id/card_linear_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/notificationText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="hello"/>
<TextView
android:id="@+id/notificationTex"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="hello2"/>
</LinearLayout>
</android.support.v7.widget.CardView>
我天真地希望能給我兩張帶有hello和hello2的卡片,但是我所看到的只是一張帶有hello的卡片-第二張卡片丟失了。 如何使用CardView創建多張卡?
可以將cardview視為ViewGroup,例如線性布局或相對布局。 如果要使用兩個cardview,請使用兩個cardview並將根布局保持為線性或相對布局。
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:layout_below="@+id/waitingHeader"
card_view:cardCornerRadius="4dp">
<TextView
android:id="@+id/notificationText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="hello"/>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:layout_below="@+id/waitingHeader"
card_view:cardCornerRadius="4dp">
<TextView
android:id="@+id/notificationTex"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="hello2"/>
</android.support.v7.widget.CardView>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.