在Android中,默认情况下ImageView是一个矩形.如何在ImageView中将其设置为圆角矩形(将我的Bitmap的所有4个角切掉为圆角矩形)?
android rounded-corners imageview android-image android-imageview
我知道有很多链接可以制作ImageView圆角.但我正在使用Picasso库进行图像加载..我引用链接获取结果.但问题是我正在使用它ListView并且对于第LIstView's一个项目ImageView它的工作完全正常但是对于剩下的一次转换不起作用.
从android 3.0 开始,硬件加速开启的设备不再支持clipPath()方法.(阅读本文了解更多详情).
我正在使用画布,我需要绘制圆形图像.关于我该怎么做的任何想法?
*我无法关闭硬件加速,我正在寻找其他解决方案.
回答:Tnx @Malcolm的答案.我发现了一个展示这种技术的好例子,它基本上是一个面具.
是否有合理的方式与毕加索做圆角
大多数关于圆角的毕加索建议都建议使用转换,但我没有看到一个例子,它不会在转换过程中创建额外的位图.
这似乎是因为Picasso只使用位图,而使用圆角的技巧使用了这样一个事实:你可以合理有效地动态绘制圆角(大多数解决方案使用类似于http://www.curious-creature的内容. org/2012/12/11/android-recipe-1-image-with-rounded-corners /).
通过将ImageView的类型更改为采用自定义drawable的东西,可以将Volley的类型更改为圆形角落.由于Picasso需要位图(至少,只有位图 - >位图转换),所以这是不对的,因为drawable转换为位图会在过程中创建一个位图.
一个解决方案就是在我自己的分支中修改毕加索的工作,它添加了一个位图 - >可绘制的变换,但我想有更好的方法来解决这个问题.
我不想在视图顶部绘制9个补丁以给出圆角的外观.
我的图像边缘锐利. 
tile_mode.xml
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/background"
android:tileMode="repeat">
</bitmap>
Run Code Online (Sandbox Code Playgroud)
back.xml
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/tile_mode" />
<item>
<shape>
<solid/>
<stroke android:width="1dip" android:color="#225786" />
<corners android:radius="10dip"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>
</item>
Run Code Online (Sandbox Code Playgroud)
layout.xml
<LinearLayout
android:id="@+id/frame1"
android:background="@drawable/back"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我将图像设置为此布局的背景并为其绘制边框但问题是图像是带有锐边的正方形,而我在xml中绘制的边框是圆角.那么如何使图像也圆角?
我有一个文本视图,带有在 TextView 中呈现的图标。它有一个图像。我已经设置在文本的左侧。但我需要将图标设置为圆形。
我如何在java中设计它?
我的代码设置在左侧。
textview.setCompoundDrawablesWithIntrinsicBounds(
image, 0, 0, 0);
Run Code Online (Sandbox Code Playgroud)
如何为上述 textview drawableleft 图像设计圆形图像。
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="fill_vertical"
android:ellipsize="end"
android:layout_marginTop="5dp"
android:layout_marginBottom="-10dp"
android:gravity="center"
android:layout_marginLeft="15dp"
android:minHeight="24dp"
android:paddingLeft="@dimen/spacing_d2"
android:paddingRight="@dimen/spacing_d2"
android:tag="@string/tag_font_h_regular"
android:fontFamily="@font/cachetbook"
android:textColor="@color/white_new"
android:textSize="12dp"
tools:text="Universal Orlando Resort"/>
Run Code Online (Sandbox Code Playgroud)