【问题标题】:Square Image View on RecyclerView ItemRecyclerView 项目上的方形图像视图
【发布时间】:2016-01-21 04:59:35
【问题描述】:

我想在我的recyclerView 左侧有一个方形 ImageView。

我们如何实现这一目标?我希望有一个没有硬编码的解决方案。

有什么想法吗?

<RelativeLayout
    android:id="@+id/containerView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginLeft="12dp"
    android:layout_marginTop="12dp"
    android:layout_marginRight="12dp"
    android:layout_marginBottom="12dp"
    android:padding="0dp">

    <ImageView
        android:id="@+id/profileImageView"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"/>

    <TextView
        android:id="@+id/nameTextView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="12dp"
        android:layout_toRightOf="@+id/profileImageView"
        android:layout_above="@+id/messageTextView"
        android:gravity="center_vertical"
        android:includeFontPadding="false"
        android:singleLine="true"
        android:textAllCaps="false"
        android:textAlignment="textStart"
        android:text="Username"/>

    <TextView
        android:id="@+id/messageTextView"
        android:layout_width="match_parent"
        android:layout_marginLeft="12dp"
        android:layout_alignParentBottom="true"
        android:layout_toRightOf="@+id/rankProfileImageView"/>

</RelativeLayout>>

【问题讨论】:

  • @ShajeelAfzal 我相信wrap_contentmatch_parent 都做不到
  • 我认为你的图片是圆形的,背面是透明的......通常你的代码看起来还可以......
  • @Tanimreja 我需要在图像上具有相同的高度和宽度,无论大小如何
  • 你的图片是从drawable还是sd卡加载的?
  • 您应该硬编码宽度和高度。试试 48dp

标签: android android-layout android-recyclerview


【解决方案1】:

使用下面的库在圆形视图中显示图像:

https://github.com/siyamed/android-shape-imageview

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-07
    • 1970-01-01
    • 2017-09-02
    • 2021-03-17
    • 2022-07-29
    • 1970-01-01
    • 2016-01-09
    • 1970-01-01
    相关资源
    最近更新 更多