Android hide and removing the image in imageview

前端 未结 4 1257
误落风尘
误落风尘 2021-02-19 11:38

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

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

answerSt         


        
相关标签:
4条回答
  • 2021-02-19 12:26

    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"/>
    
    0 讨论(0)
  • 2021-02-19 12:33

    try this imageview.setVisibility(ImageView.INVISIBLE);

    0 讨论(0)
  • 2021-02-19 12:36

    You can use answerState1.setVisibility(View.INVISIBLE); to make view invisible and answerState1.setVisibility(View.Gone); to make the view invisible.

    0 讨论(0)
  • 2021-02-19 12:37

    Try the following code:

    ImageView im = (ImageView)findViewById(R.id.imageView1);
    im.setVisibility(View.INVISIBLE);
    im.getLayoutParams().height = 0;
    
    0 讨论(0)
提交回复
热议问题