Android自定义View实现商城商品详情图片列表

2020-07-12  本文已影响0人  itfitness

目录

目录

前言

由于最近做了好几个需要类似商城展示商品详情的列表效果,所以索性就封装了一个通用版的控件,只需要简单的几行代码就能实现所需效果。

效果展示

实现原理

其实实现原理很简单,就算自己用listView或者RecyclerView也能实现。在Item布局中只需要使用一个ImageView即可,宽度填充父元素,高度自适应,拉伸类型为fitXY。

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <ImageView
        android:id="@+id/ftlib_item_goodsdetailsview_img"
        android:adjustViewBounds="true"
        android:scaleType="fitXY"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</FrameLayout>

案例源码

https://github.com/myml666/FitnessLib

上一篇 下一篇

猜你喜欢

热点阅读