安卓一行两个的居中图像列表

本文介绍如何在安卓应用中实现一行显示两个图像并居中的布局方法。通过定义特定的item.xml模板和自定义ImageListAdapter,重写相关方法,包括获取图像数量、设置图像以及ListView的使用,最终达到预期的居中显示效果。
摘要由CSDN通过智能技术生成

安卓一行两个的居中图像列表

定义一个item.xml作为视频摆放的模板

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"

    android:paddingTop="10dp"
    android:gravity="center|top"
    >

    <ImageView
        android:id="@+id/first_im_item"
        android:layout_width="180dp"
        android:layout_height="246dp"
        android:background="@drawable/check_button"
        android:scaleType="fitXY"
        ></ImageView>
    <ImageView
        android:id="@+id/second_im_item"
        android:layout_width="180dp"
        android:layout_height="246dp"
        android:background="@drawable/check_button"
        android:layout_toRightOf="@id/first_im_item"
        android:layout_marginLeft="10dp"
        android:scaleType="fitXY"
        ></ImageView>

</RelativeLayout>

这样可以居中显示,如图所示

然后定义一个ImageListAdapter类,这个类继承BaseAdapter,这个类中有两个属性

private List<Map<String, Object>> li
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值