我想從視圖(android.view.View)中刪除基於codition.condition的imageview,該圖像視圖的src。如何從視圖中刪除imageView。請幫助從視圖中刪除Imageview
0
A
回答
1
例子:
LinearLayout linearLayout;
ImageView imageView;
if (condition) {
linearLayout.removeView(imageView);
}
我需要更多的信息來提供更好的答案。
1
要刪除imageview
,使用
if(condition) {
imageView.setVisibility(View.GONE);
}
爲了使imageview
隱藏/不可見,使用
if(condition) {
imageView.setVisibility(View.INVISIBLE);
}
帶回imageview
,使用
imageView.setVisibility(View.VISIBLE);
5
通過刪除如果你意味着隱藏的ImageView的,基於特定條件下,做這樣的事情:
if (your_condition) {
your_image_view.setVisibility(View.GONE);
} else {
your_image_view.setVisibility(View.VISISBLE);
}
如果您需要刪除當前設置爲ImageView
形象,在上面的if ... else
做到這一點(基於條件)
your_image_view.setImageResource(android.R.color.transparent);
OR
your_image_view.setImageBitmap(null);
如果需要取下的ImageView的完全,請撥打本,在if....else
,在ImageView's
容器上:
container.removeView(your_image_view);
+1
謝謝你的「android.R.color.transparent」訣竅:) [順便說一句,我們這裏有人不喜歡接受好答案] – dentex 2016-08-17 14:36:30
隱藏'ImageView'?或者從ImageView中移除圖像?嘗試在問題中添加更多的細節。 – 2013-02-18 05:32:02
如果你想完全刪除imageview你使用removeView(視圖),但如果你想隱藏圖像視圖,你可以使用ImageView.setVisibility(ImageView.INVISIBLE) – Pragnani 2013-02-18 05:37:43