android - Android 中的圆形 ImageView ,无需使用任何外部库

标签 android imageview

有没有办法在不使用任何外部库的情况下在 Android 中制作圆形 ImageView ? android设计库中的东西?我应该能够使用代码在运行时设置图像。

最佳答案

您可以将 ImageView 放在 CardView 中并设置其角半径。 简单的例子

<android.support.v7.widget.CardView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        card_view:cardCornerRadius="25dp"
        card_view:cardPreventCornerOverlap="false">

        <ImageView
            android:layout_width="50dp"
            android:layout_height="50dp"/>
    </android.support.v7.widget.CardView>

请注意,角半径应比图像尺寸短两倍。

关于android - Android 中的圆形 ImageView ,无需使用任何外部库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46113518/

相关文章:

android - 更改 android 字体不起作用

android - 让按钮看起来被按下

android - RoundedImageView - 添加填充而不裁剪图像

android - 拖放:ImageView 不会在屏幕上一直移动

android - 在 Android 应用程序中搜索最佳提供商

Android SQLite查询: "queryNumEntries .. is not applicable for the arguments"?

android - ImageView 中的清晰图像

android - ImageView 不拉伸(stretch)(Android)?

Android - 方形表格布局

android - 请参阅下面 XML 布局中的 ID