Tag: imageview

如何使圆角的ImageView?

在Android中,默认情况下ImageView是一个矩形。 我怎样才能使它在ImageView中的一个圆角的矩形(剪切掉我的位图的所有四个角落是圆角矩形)?

检测视图碰撞并防止覆盖

当我正在使用Kotlin android框架进行一个益智游戏时,我被困在了一点,当我无法弄清楚如何防止imageViews在移动时互相重叠时,我尝试了很多解决方案,没有任何工作,如果任何人可以告诉我如何防止它们重叠或告诉我如何检测碰撞的正确方法。 这里是我用来检测碰撞的代码: //onCreate getRundomPosition() //this method is used to put the imageView in some random position imageView.getDrawingRect(rc1) imageView2.getDrawingRect(rc2) imageView3.getDrawingRect(rc3) imageView4.getDrawingRect(rc4) imageView5.getDrawingRect(rc5) imageView6.getDrawingRect(rc6) imageView7.getDrawingRect(rc7) //the function I use to check collision it’s called after a swipe event fun checkIntersection(rc:Rect):Boolean{ var b:Boolean if(Rect.intersects(rc,rc1)) b=true else if(Rect.intersects(rc,rc2)) b=true else if(Rect.intersects(rc,rc3)) b=true else if(Rect.intersects(rc,rc4)) b=true else if(Rect.intersects(rc,rc5)) b=true […]

在循环中的图像之间旋转

我创建了一个按钮来在循环模式下切换两个图像,但我无法使它工作。 当我第二次按下按钮时,图像不会发生变化。 这是我的代码: 科特林: IBRotate.setOnClickListener() { body.setTag(1) if(body.getTag() == 1) { body.setImageResource(R.drawable.back_woman) body.setTag(2) } else if(body.getTag() == 2) { body.setImageResource(R.drawable.front_woman) body.setTag(1) } } XML:

从一个字符串获取Android的ID资源

在我的Kotlin应用程序中,我有一些ImageViews (在activity_main.xml ): imageView_0 , imageView_1 , imageView_2和imageView_3 。 我如何从0到3循环访问视图? 这不会起作用: val imageView: ImageView = findViewById(“R.id.imageView_” + index) as ImageView

如何将imageview转换为kotlin中的bytearray

如何将imageview转换为bytearray kotlin android 在java中 Bitmap bitmap = ((BitmapDrawable)image.getDrawable()).getBitmap(); ByteArrayOutputStream stream=new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 90, stream); byte[] image=stream.toByteArray(); return image

如何使用代码设置ImageView的边距,而不是xml

我想添加一个未知数量的ImageView视图到我的布局与保证金。 在XML中,我可以像这样使用layout_margin : <ImageView android:layout_margin="5dip" android:src="@drawable/image" /> 有ImageView.setPadding() ,但没有ImageView.setMargin() 。 我认为这是沿着ImageView.setLayoutParams(LayoutParams) ,但不知道该怎么喂。 有人知道吗?

使用Glide库设置完成图像加载后进度条的可见性

您好我想有一个图像的进度条,这将显示图像加载时,但图像加载完成后,我想把它设置为消失。 早些时候,我正在使用毕加索图书馆。 但我不知道如何使用Glide库。 我有一些资源就绪功能的想法,但我不知道如何使用它。 任何人都可以帮我吗? 毕加索图书馆的代码 Picasso.with(mcontext).load(imgLinkArray.get(position).mUrlLink) .into(imageView, new Callback() { @Override public void onSuccess() { progressBar.setVisibility(View.GONE); } @Override public void onError() { } }) ; 现在我怎么能用Glide做到这一点? Glide.with(mcontext).load(imgLinkArray.get(position).mUrlLink) .into(imageView); 我能够加载图像与Glide这个,但我怎么能写progressBar.setVisibility(View.GONE); 在代码中的某处如果图像被加载?

如何将imageview转换为kotlin中的bytearray

如何将imageview转换为bytearray kotlin android 在java中 Bitmap bitmap = ((BitmapDrawable)image.getDrawable()).getBitmap(); ByteArrayOutputStream stream=new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 90, stream); byte[] image=stream.toByteArray(); return image

Kotlin if语句即使执行错误也是如此

我试图检查一个配置文件是否有一个图像的URL设置,如果是的话,加载到一个ImageView : val hasImage = image != null && image.isNotBlank() if (hasImage) { Picasso.with(context).load(image).into(row.image) } image是可以空的字符串。 问题是,即使hasImage是false,它仍然加载图像,你可以看到: 但是,如果我做val hasImage = false它的行为如预期。 对于这里发生的事情,我感到非常困惑。 为什么if条件仍在执行?

Android Kotlin .visibility

我有这样的代码,应该使图像可见,但我不知道它应该如何写入Kotlin。 我正在尝试在Kotlin中使用.visibility ,我不知道该怎么给它一个价值。 它基于setVisibility() 。 码: fun hacerVisibleLaFoto(v: View) { imageView.visibility = 1; } 我把1放在值域中,因为在那里需要一个整数值,这是我的占位符值,直到我找到真正的值。 =号后面应该显示的值是什么?