繁体   English   中英

只有彩色圆角的imageview

[英]imageview with only color rounded corner

我试图有一些彩色的圆角imageviews !!!

我定义我的图像视图是这样的:

<ImageView
        android:id="@+id/game_play_color_image_1"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:layout_margin="@dimen/game_play_values_colors_margin"
        android:layout_weight="1"
        android:background="@drawable/soft_corner"
        android:scaleType="fitXY" />

并且背景定义:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >

<stroke
    android:width="3dp"
    android:color="#ffffff" />

<solid android:color="#ffffff" />

<padding
    android:bottom="1dp"
    android:left="1dp"
    android:right="1dp"
    android:top="1dp" >
</padding>

<corners android:radius="5dp" >
</corners>

我像这样设置我的图像视图的颜色

(颜色是我自己的类,您可以看到它具有3个属性)

imageView.setBackgroundColor(Color.rgb(color.getRed(), color.getGreen(), color.getBlue()));

但是问题是,我的图像视图没有圆角!

怎么了?

提前致谢

因为您要重新设置背景...如果您已经有背景资源,请替换它。 如果您想让@drawable/soft_corner具有纯色作为imageview的背景,请尝试使用@drawable/soft_corner作为imageResource并使用android:color/transparent将矩形的颜色设置为android:color/transparent

这对我有用,所以您使用它会为您提供帮助

<solid android:color="#FFFFFF" />

<stroke

    android:width="1dp"
    android:color="#2f6699" />
<corners 

    android:topLeftRadius="10dp"
    android:topRightRadius="10dp"
    android:bottomLeftRadius="10dp"
    android:bottomRightRadius="10dp"

    />

您需要根据需要创建自定义ImageView。 检查以获取详细信息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM