android imageview垂直居中,android – 在片段中垂直居中RecyclerView

首先,我在

Android中有点新手.

我目前有一个加载片段的活动,在这个片段中,我实例化了一个RecyclerView(水平方向).

这是我目前的布局:

我的主要:

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="@color/red"

android:orientation="vertical">

android:id="@+id/container"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="@color/green">

我的片段:

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:gravity="center_vertical"

android:orientation="vertical"

android:background="@color/yellow">

android:id="@+id/fragment_atelier_recycler_view"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_centerVertical="true"

android:layout_centerInParent="true"

android:background="#FFE5E5E5"

android:scrollbarStyle="insideOverlay"

/>

我的RecyclerView适配器的项目布局:

android:layout_width="wrap_content" android:layout_height="wrap_content"

android:background="@color/gray">

android:id="@+id/item_icon"

android:layout_width="64dp"

android:layout_height="64dp"

android:layout_marginLeft="8dp"

android:layout_marginRight="8dp"

android:layout_marginTop="1dp"

android:layout_marginBottom="1dp"

android:layout_gravity="center"

android:contentDescription="icon"/>

我试着在几个小时内垂直居中我的RecyclerView而没有成功(通过使用gravity,layout_centerVertical等……).

也许我错过了关于wrap_content / match_parent或线性/相对规格的内容.

在此先感谢,祝你有个美好的一天:)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值