Android隐藏和删除imageview中的图像 [英] Android hide and removing the image in imageview

查看:703
本文介绍了Android隐藏和删除imageview中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在android中的imageview中删除图像以及如何隐藏整个图像。

How to remove a image in imageview in android and also how to hide the entire image.

这里我通过以下代码在imageview中放置了一个图像。 / p>

Here I have placed an image in imageview by the below code.

answerState1.setBackgroundResource(R.drawable.correct);

我不知道如何删除或隐藏图像。我也是Android开发的新手。

I don't know how to remove or hide the image. Also I am entirely new to android development.

推荐答案

您可以使用以下方法调用设置图像的可见性:

You can set the visibility of an image with the following method calls:

answerState1.setVisibility(View.GONE);  // hide image (make the view gone)

answerState1.setVisibility(View.VISIBLE);  // make image visible

answerState1.setVisibility(View.INVISIBLE);  // make image invisible

在用户界面中,您还可以执行以下操作:

In UI, you can also do something like the following:

<ImageView android:id="@+id/imgPreview" 
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
android:visibility="gone"/>

这篇关于Android隐藏和删除imageview中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆