相关疑难解决方法(0)

如何制作带圆角的ImageView?

在Android中,默认情况下ImageView是一个矩形.如何在ImageView中将其设置为圆角矩形(将我的Bitmap的所有4个角切掉为圆角矩形)?

android rounded-corners imageview android-image android-imageview

537
推荐指数
27
解决办法
42万
查看次数

ImageView循环通过xml

我想把我的任何图像ImageView变成带边框的圆形.

我搜索但找不到任何有用的信息(我试过的任何东西都不起作用).

我如何通过xml实现这一点:ImageView使用某个src 创建一个并使其带边框的圆形?

xml android imageview

180
推荐指数
14
解决办法
39万
查看次数

如何在圆形imageView android上添加阴影和边框?

我用这个问题创建了一个CircularImageView:在android中创建圆形图像视图

GitHub上下载项目

1)这是CircularImageView类:

public class CircularImageView extends ImageView {
    public CircularImageView(Context context) {
        super(context);
    }

    public CircularImageView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public CircularImageView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        Drawable drawable = getDrawable();
        if (drawable == null) {
            return;
        }

        if (getWidth() == 0 || getHeight() == 0) {
            return; 
        }
        Bitmap b =  ((BitmapDrawable)drawable).getBitmap() ;
        Bitmap bitmap = b.copy(Bitmap.Config.ARGB_8888, true);      

        Bitmap roundBitmap = …
Run Code Online (Sandbox Code Playgroud)

java android imageview

60
推荐指数
2
解决办法
7万
查看次数

如何使ImageView成圆形?

我想做那样的事.

列表视图中的图像

这是一个列表视图行,其中包含名称和用户图像.

我做了一些搜索并完成了图像循环,但不是完美的解决方案.任何帮助都会帮助我.

我的代码添加到Image Loader类

public Bitmap processBitmap(Bitmap bitmap) {
    int pixels = 0;
    if (mRound == 0)
        pixels = 120;
    else
        pixels = mRound;
    Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
            bitmap.getHeight(), Config.ARGB_8888);
    Canvas canvas = new Canvas(output);

    final int color = 0xff424242;
    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
    final RectF rectF = new RectF(rect);
    final float roundPx = pixels;

    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    canvas.drawRoundRect(rectF, roundPx, roundPx, paint);

    paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
    canvas.drawBitmap(bitmap, …
Run Code Online (Sandbox Code Playgroud)

android imageview

28
推荐指数
3
解决办法
6万
查看次数

使图像呈圆形,带有白色圆形边框

如何使图像圆形并给它白色圆形边框?是否有必要使用两个图像视图 - 一个用于图像,另一个用于白色边框?有没有其他方法可以做到这一点?

layout geometry android drawing imageview

11
推荐指数
4
解决办法
3万
查看次数

xml中的Android可绘制形状 - 在正方形中创建一个透明圆圈

有没有办法从xml中的另一个形状中减去或"剪切"一个形状?我想在中心创建一个带有透明圆孔的白色正方形...主要是因为我不想做位图操作来制作圆形图像:).

是的,我知道这个解决方案(如何在Android中创建圆形ImageView?)存在.

在此输入图像描述

android android-xml android-shape

9
推荐指数
1
解决办法
3304
查看次数

如何使用volley库android创建圆角图像

我从服务器获取方形的图像网址我必须使它成为圆角图像.实际上我正在使用排球库,我知道如何使用通用图像加载器和毕加索库创建圆角图像.在排球库我设置图像在网络imageview像setimageUrl请帮助我

 holder.ivImage.setImageUrl(url, imageLoader);
Run Code Online (Sandbox Code Playgroud)

android android-volley networkimageview

7
推荐指数
3
解决办法
9745
查看次数

在ImageView中设置圆角图像

我在网站上搜索了更多,并得到了如下的许多建议

  • 使用自定义样式更改背景以设置角半径和填充(将图像设置为矩形,将背景设置为圆角)

  • 通过传递此位图和宽度(它需要更多时间加载)来解码图像和裁剪功能,从而将给定图像更改为位图

我查过了WhatsApp Chat history list and it has rounded corner images but its loaded with minimum time.

你能否建议我用WhatsApp创建带有圆形图像的listview模板的最佳方法?

我希望通过在xml页面中设置样式详细信息更改带圆角的图像.(图像宽度和高度是60 dp,我的listview也有大约60项)

参考文献:

RES/mylayout.xml:

<ImageView
        android:id="@+id/contactssnap"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:src="@drawable/contactssnap"
        android:background="@drawable/roundimage" />
Run Code Online (Sandbox Code Playgroud)

RES /绘制/ roundimage.xml:

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >
    <solid android:color="#ffffffff" />
    <stroke
        android:width="2dp"
        android:color="#90a4ae" />
    <size
        android:height="50dp"
        android:width="50dp" />
    <padding
        android:bottom="2dp"
        android:left="2dp"
        android:right="2dp"
        android:top="2dp" />
    <corners android:radius="100dp" />
</shape>
Run Code Online (Sandbox Code Playgroud)

注意:支持的Android版本从14到22

android android-listview android-xml android-imageview

7
推荐指数
6
解决办法
2万
查看次数

如何在圆形图像视图中添加图标

我有两个圆形图像视图,一个是包含配置文件pic,另一个是用于相机.以下是我的XML文件:

1. Welocome.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bg"
    android:orientation="vertical"
    tools:context=".activity.WelcomeActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="@dimen/margin40"
        android:text="Welcome to Almachat"
        android:textColor="#ffffff"
        android:textSize="25dp" />

    <FrameLayout
        android:layout_width="220dp"
        android:layout_height="220dp"
        android:layout_gravity="center"
        android:layout_marginTop="@dimen/margin10">

        <com.almabay.almachat.circularImageView.CircularImageView
            android:id="@+id/profilePic"
            android:layout_width="170dp"
            android:layout_height="170dp"
            android:layout_gravity="bottom|center_horizontal" />

        <com.almabay.almachat.circularImageView.CircularImageView
            android:id="@+id/iv_camera"
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:layout_gravity="top|right"
            android:layout_marginTop="@dimen/margin30"
            android:background="@drawable/color"
            />
    </FrameLayout>

    <TextView
        android:id="@+id/txtName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="@dimen/margin20"
        android:textColor="#ffffff"
        android:textSize="30sp"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/txtSomeText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="Some static text will be here"
        android:textColor="#ffffff"
        android:textSize="20sp" />

    <Button
        android:id="@+id/btnContinue"
        android:layout_width="150dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="@dimen/margin20"
        android:background="#F7AE21"
        android:padding="@dimen/padding20"
        android:text="Continue"
        android:textColor="#ffffff" /> …
Run Code Online (Sandbox Code Playgroud)

java android android-imageview

7
推荐指数
2
解决办法
1万
查看次数

仅底角或顶角为圆角的 ImageView

我对这个问题有答案,但我花了太多时间寻找它。这就是我创建这个问题的原因,这样对其他人来说会更容易。

您不能像通常的视图一样使用形状 @drawable 来圆化图像角。这就是为什么您需要对代码内的图像进行一些更改。

android shapes rounded-corners drawable imageview

7
推荐指数
1
解决办法
4428
查看次数