【问题标题】:How to have an expandable CardView?如何拥有可扩展的 CardView?
【发布时间】:2016-11-19 17:13:39
【问题描述】:

我现在正在尝试开发一个使用 CardViews 的应用程序,并且我希望它们可以扩展;也就是说,当有人按下 CardView 时,它应该展开以显示更多细节。我该怎么做呢?

这是对我正在尝试做的事情的直观解释;当我按下突出显示的 CardView 时,我希望它展开以显示更多信息,并能够在另一次按下时收缩;我不知道该怎么做,并且搜索互联网导致我至今没有答案。

【问题讨论】:

    标签: java android xml cardview


    【解决方案1】:

    最好的解决方案是,使用可扩展布局并将其添加到您的 CardView 中。

    <com.kyo.expandablelayout.ExpandableLayout
        android:id="@+id/expandlayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="12dp" >
    
        <ImageView
            android:id="@+id/imageview"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:contentDescription="@null"
            android:scaleType="centerCrop"
            android:src="@drawable/parent" />
    
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="6dp"
            android:contentDescription="@null"
            android:scaleType="centerCrop"
            android:src="@drawable/child"
            app:canExpand="true" />
    </com.kyo.expandable.ExpandableLayout>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-10-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-29
      • 1970-01-01
      • 1970-01-01
      • 2011-12-31
      • 2019-04-21
      相关资源
      最近更新 更多