gpt4 book ai didi

使用 CardView 的 Android L 卡片

转载 作者:行者123 更新时间:2023-11-30 02:44:43 26 4
gpt4 key购买 nike

我正在尝试使用新的 Android L SDK,但我不知道如何实现 CardView。好像我遗漏了什么 - 非常感谢任何建议!

到目前为止,我已将以下内容声明为我的 Activity 的一部分:

<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>

我天真地希望能给我两张带有 hellohello2 的卡片,但我所看到的只是一张带有 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>

关于使用 CardView 的 Android L 卡片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25264482/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com