【问题标题】:how to set a border around circle image view like instagram?如何在像 instagram 这样的圆形图像视图周围设置边框?
【发布时间】:2020-07-14 17:08:25
【问题描述】:

我想在圆形图像视图周围设置一个圆形边框,例如 instagram 故事,有人可以帮忙吗? 这是我的图像视图

<de.hdodenhof.circleimageview.CircleImageView
    android:id="@+id/profile_image"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:layout_marginStart="10dp"
    android:layout_marginTop="8dp"
    android:src="@drawable/profile1"
    app:civ_border_color="#DBDBDB"
    app:civ_border_width="1dp"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

【问题讨论】:

    标签: android geometry imageview instagram


    【解决方案1】:

    您也可以使用材质组件库提供的ShapeableImageView

    类似:

    <com.google.android.material.imageview.ShapeableImageView
        app:shapeAppearanceOverlay="@style/circularImageView"
        app:srcCompat="@drawable/...."
        app:strokeColor="@color/....."
        app:strokeWidth="1dp"
        ...
        />
    

    与:

      <style name="circularImageView">
        <item name="cornerFamily">rounded</item>
        <item name="cornerSize">50%</item>
      </style>
    

    注意:至少需要1.2.0-alpha03版本。

    【讨论】:

    • 材料设计大师归来:)
    猜你喜欢
    • 1970-01-01
    • 2023-03-18
    • 1970-01-01
    • 2015-04-26
    • 1970-01-01
    • 2022-11-23
    • 2012-10-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多